Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
xaviml committed Feb 24, 2021
2 parents cb9c814 + 880e219 commit 14b5eff
Show file tree
Hide file tree
Showing 38 changed files with 771 additions and 362 deletions.
2 changes: 1 addition & 1 deletion .cz.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.commitizen]
name = "cz_conventional_commits"
version = "4.6.0"
version = "4.7.0b0"
tag_format = "v$major.$minor.$patch$prerelease"
version_files = [
"apps/controllerx/cx_version.py",
Expand Down
17 changes: 8 additions & 9 deletions .github/ISSUE_TEMPLATE/new_device.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,23 @@ assignees: xaviml

## Device Information

* Device Model: [ eg. E1743 ]
* Device Description: [ eg. IKEA TRADFRI E1743 wireless dimmer ]
* Device Manufacturer: [ eg. IKEA ]
- Device Model: [ eg. E1743 ]
- Device Description: [ eg. IKEA TRADFRI E1743 wireless dimmer ]
- Device Manufacturer: [ eg. IKEA ]

## Integrations

If possible, provide the event mappings for the different actions that can be performed on the controller. Specify the integration.
<!-- If possible, provide the event mappings for the different actions that can be performed on the controller. Specify the integration.
If you can provide mappings for multiple integrations, copy the section below as many times as needed.
If you can provide mappings for multiple integrations, copy the section below as many times as needed. -->

### Integration: [ Choose from `z2m | deconz | zha` ]

#### Actions

* `button_xyz_press`: Sent when button xyz is pressed
* `button_xyz_hold`: Sent when button xyz is held
- `button_xyz_press`: Sent when button xyz is pressed
- `button_xyz_hold`: Sent when button xyz is held

#### Notes

(Optional) Additional notes for the integration, eg. known bugs, issues or limitations of the device for the specified integration.

<!-- (Optional) Additional notes for the integration, eg. known bugs, issues or limitations of the device for the specified integration. -->
20 changes: 10 additions & 10 deletions .github/workflows/hacs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
name: HACS Compliant

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
# events but only for the main branch
on:
push:
branches: [dev, master]
branches: [dev, main]
pull_request:
branches: [dev, master]
branches: [dev, main]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
Expand All @@ -19,10 +19,10 @@ jobs:

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: HACS validation
uses: hacs/integration/action@main
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CATEGORY: appdaemon
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: HACS validation
uses: hacs/integration/action@main
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CATEGORY: appdaemon
5 changes: 3 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ _Note: I recommend working with Python 3.6 since is the minimum version supporte
New controllers need to be added into the `apps/controllerx/devices/` and you will need to define the mapping for the integration you are adding support to.

Also, the controller will need to be added to the documentation. You will need to create:

- YAML file in `docs/_data/controllers`
- MarkDown file in `docs/controllers`
- JPEG image in `docs/assets/img`
Expand Down Expand Up @@ -121,7 +122,7 @@ git checkout -b <username>-<remote-branch> <username>/<remote-branch>

## Deployment

Thanks to the Azure Pipelines, we are able to deploy by just creating a new tag on git. So first, we will need to bump version with `commitizen` by running the following line in the `master` branch:
Thanks to the Azure Pipelines, we are able to deploy by just creating a new tag on git. So first, we will need to bump version with `commitizen` by running the following line in the `main` branch:

```shell
cz bump --no-verify
Expand All @@ -130,7 +131,7 @@ cz bump --no-verify
`--prerelease beta` tag can be added to create a pre-release. Note that you can also add `--dry-run` to see which version will bump without commiting anything. Then, we can directly push the tags:

```shell
git push origin master --tags
git push origin main --tags
```

This will automatically generate a GitHub release with the changes for that release.
4 changes: 2 additions & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ pytest-mock = "==3.5.1"
pytest-timeout = "==1.4.2"
mock = "==4.0.3"
pre-commit = "==2.10.1"
commitizen = "==2.14.2"
mypy = "==0.800"
commitizen = "==2.15.2"
mypy = "==0.812"
flake8 = "==3.8.4"
isort = "==5.7.0"
controllerx = {path = ".", editable = true}
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
[![logo](https://github.com/xaviml/controllerx/raw/dev/docs/android-chrome-192x192.png)](https://github.com/xaviml/controllerx/releases)

[![hacs_badge](https://img.shields.io/badge/HACS-Default-orange.svg?style=for-the-badge)](https://github.com/hacs/integration)
[![azure-pipelines-build](https://img.shields.io/azure-devops/build/xaviml93/ControllerX/1/master.svg?style=for-the-badge)](https://dev.azure.com/xaviml93/ControllerX/_build/latest?definitionId=1&branchName=master)
[![azure-pipelines-build](https://img.shields.io/azure-devops/build/xaviml93/ControllerX/1/main.svg?style=for-the-badge)](https://dev.azure.com/xaviml93/ControllerX/_build/latest?definitionId=1&branchName=main)
[![last-release](https://img.shields.io/github/v/release/xaviml/controllerx.svg?style=for-the-badge)](https://github.com/xaviml/controllerx/releases)
[![downloads-latest](https://img.shields.io/github/downloads/xaviml/controllerx/latest/total?style=for-the-badge)](http://github.com/xaviml/controllerx/releases/latest)
[![azure-pipelines-coverage](https://img.shields.io/azure-devops/coverage/xaviml93/ControllerX/1/master.svg?style=for-the-badge)](https://dev.azure.com/xaviml93/ControllerX/_build/latest?definitionId=1&branchName=master)
[![Codacy Badge](https://img.shields.io/codacy/grade/542f29ab55a449099488601ec7400563/master?style=for-the-badge)](https://app.codacy.com/manual/xaviml/controllerx?utm_source=github.com&utm_medium=referral&utm_content=xaviml/controllerx&utm_campaign=Badge_Grade_Dashboard)
[![azure-pipelines-coverage](https://img.shields.io/azure-devops/coverage/xaviml93/ControllerX/1/main.svg?style=for-the-badge)](https://dev.azure.com/xaviml93/ControllerX/_build/latest?definitionId=1&branchName=main)
[![community-topic](https://img.shields.io/badge/community-topic-blue?style=for-the-badge)](https://community.home-assistant.io/t/controllerx-bring-full-functionality-to-light-and-media-player-controllers/148855)
[![buy-me-a-beer](https://img.shields.io/badge/sponsor-Buy%20me%20a%20beer-orange?style=for-the-badge)](https://www.buymeacoffee.com/xaviml)

Expand Down Expand Up @@ -40,4 +39,4 @@ If you like this project, don't forget to star it :)
## Contributing
If you want to contribute to this project, check [CONTRIBUTING.md](https://github.com/xaviml/controllerx/blob/master/CONTRIBUTING.md).
If you want to contribute to this project, check [CONTRIBUTING.md](https://github.com/xaviml/controllerx/blob/main/CONTRIBUTING.md).
8 changes: 8 additions & 0 deletions apps/controllerx/cx_core/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,5 +488,13 @@ def get_zha_action(self, data: EventData) -> Optional[str]:
"""
return None

def get_lutron_caseta_actions_mapping(self) -> Optional[DefaultActionsMapping]:
"""
Controllers can implement this function. It should return a dict
with the command that a controller can take and the functions as values.
This is used for Lutron support.
"""
return None

def get_predefined_actions_mapping(self) -> PredefinedActionsMapping:
return {}
10 changes: 5 additions & 5 deletions apps/controllerx/cx_core/custom_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ async def init(self) -> None:
level="WARNING",
ascii_encode=False,
)
await super().init()
await super().init() # pragma: no cover


class CustomMediaPlayerController(MediaPlayerController):
Expand All @@ -22,7 +22,7 @@ async def init(self) -> None:
level="WARNING",
ascii_encode=False,
)
await super().init()
await super().init() # pragma: no cover


class CustomSwitchController(SwitchController):
Expand All @@ -32,7 +32,7 @@ async def init(self) -> None:
level="WARNING",
ascii_encode=False,
)
await super().init()
await super().init() # pragma: no cover


class CustomCoverController(CoverController):
Expand All @@ -42,7 +42,7 @@ async def init(self) -> None:
level="WARNING",
ascii_encode=False,
)
await super().init()
await super().init() # pragma: no cover


class CallServiceController(Controller):
Expand All @@ -52,4 +52,4 @@ async def init(self) -> None:
level="WARNING",
ascii_encode=False,
)
await super().init()
await super().init() # pragma: no cover
26 changes: 26 additions & 0 deletions apps/controllerx/cx_core/integration/lutron_caseta.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from typing import Optional

from appdaemon.plugins.hass.hassapi import Hass # type: ignore
from cx_const import DefaultActionsMapping
from cx_core.integration import EventData, Integration


class LutronIntegration(Integration):
name = "lutron_caseta"

def get_default_actions_mapping(self) -> Optional[DefaultActionsMapping]:
return self.controller.get_lutron_caseta_actions_mapping()

def listen_changes(self, controller_id: str) -> None:
Hass.listen_event(
self.controller,
self.callback,
"lutron_caseta_button_event",
serial=controller_id,
)

async def callback(self, event_name: str, data: EventData, kwargs: dict) -> None:
button = data["button_number"]
action_type = data["action"]
action = f"button_{button}_{action_type}"
await self.controller.handle_action(action, extra=data)
14 changes: 14 additions & 0 deletions apps/controllerx/cx_devices/ikea.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,3 +486,17 @@ def get_zha_actions_mapping(self) -> DefaultActionsMapping:
"down_close": Cover.TOGGLE_CLOSE,
"stop": Cover.STOP,
}


class E1812LightController(LightController):
def get_z2m_actions_mapping(self) -> DefaultActionsMapping:
return {
"on": Light.TOGGLE,
"brightness_move_up": Light.HOLD_BRIGHTNESS_TOGGLE,
"brightness_stop": Light.RELEASE,
}


class E1812SwitchController(SwitchController):
def get_z2m_actions_mapping(self) -> DefaultActionsMapping:
return {"on": Switch.TOGGLE}
Loading

0 comments on commit 14b5eff

Please sign in to comment.