Skip to content

Commit

Permalink
Merge branch 'master' into fix_state_handling
Browse files Browse the repository at this point in the history
  • Loading branch information
litinoveweedle committed Sep 27, 2024
2 parents d5399d9 + a5ddb97 commit aff94b8
Show file tree
Hide file tree
Showing 28 changed files with 5,542 additions and 249 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/reformat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ jobs:
- name: Markdown autodocs
uses: dineshsonachalam/markdown-autodocs@v1.0.7
with:
output_file_paths: '[./docs/CLIMATE_CODES.md, ./docs/FAN_CODES.md, ./docs/MEDIA_PLAYER_CODES.md]'
output_file_paths: '[./docs/CLIMATE_CODES.md, ./docs/FAN_CODES.md, ./docs/MEDIA_PLAYER_CODES.md, ./docs/LIGHT_CODES.md]'
commit_message: Update docs - include valid device files
18 changes: 16 additions & 2 deletions docs/README.md → README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

## Overview

SmartIR is a custom integration for controlling **climate devices**, **media players** and **fans** via infrared controllers.
SmartIR is a custom integration for controlling **climate**, **media player**, **fan** and **light** devices via infrared controllers.

SmartIR currently supports the following controllers:

Expand Down Expand Up @@ -53,6 +53,7 @@ The resulting directory structure should look similar to this:
|-- controller.py
| |-- fan.py
| |-- media_player.py
|--light.py
| |-- codes/
| |-- climate/
| |-- 1000.json
Expand All @@ -62,6 +63,9 @@ The resulting directory structure should look similar to this:
| |-- .....
| |-- media_player/
| |-- 1000.json
| |-- .....
|-- light/
| |-- 1000.json
| |-- .....
| |-- custom_codes/
| |-- climate/
Expand All @@ -72,12 +76,21 @@ The resulting directory structure should look similar to this:
| |-- .....
| |-- media_player/
| |-- 1000.json
| |-- .....
|-- light/
| |-- 1000.json
| |-- .....
```

## Device Data - IR Codes

To properly function, specification of your controlled device data including IR codes shall exists either in `codes` or in `custom_codes` directory as a .JSON file. When installed both using HACS or manual method, `codes` directory is populated by device data files maintained by this project. If you would like to create your own device data file, place it in the `custom_codes` class `climate|fan|media_player` subdirectory, this directory is persistent and will be manitained accross HACS updates. **Please don't forget to create [PR](https://github.com/litinoveweedle/SmartIR/pulls) for this new device data file and I will try to include it in a new releases.**
To properly function, specification of your controlled device data including IR codes shall exists either in `codes` or in `custom_codes` directory as a .JSON file. When installed both using HACS or manual method, `codes` directory is populated by device data files maintained by this project. If you would like to create your own device data file, place it in the `custom_codes` class `climate|fan|media_player|light` subdirectory, this directory is persistent and will be manitained accross HACS updates. **Please don't forget to create [PR](https://github.com/litinoveweedle/SmartIR/pulls) for this new device data file and I will try to include it in a new releases.**

### Convert IR Codes from Broadlink to Z06/UFO-R11

Using https://gist.github.com/svyatogor/7839d00303998a9fa37eb48494dd680f?permalink_comment_id=5153002#gistcomment-5153002 you can convert Broadlink code file.

Example: `python3 broadlink_to_tuya.py 1287.json > 9997.json`

## Platform setup instructions

Expand All @@ -86,6 +99,7 @@ Click on the links below for instructions on how to configure each platform.
- [Climate platform](/docs/CLIMATE.md)
- [Media Player platform](/docs/MEDIA_PLAYER.md)
- [Fan platform](/docs/FAN.md)
- [Light platform](/docs/LIGHT.md)

## See also

Expand Down
463 changes: 463 additions & 0 deletions codes/climate/1142.json

Large diffs are not rendered by default.

425 changes: 425 additions & 0 deletions codes/climate/1395.json

Large diffs are not rendered by default.

625 changes: 625 additions & 0 deletions codes/climate/1705.json

Large diffs are not rendered by default.

477 changes: 477 additions & 0 deletions codes/climate/1706.json

Large diffs are not rendered by default.

346 changes: 346 additions & 0 deletions codes/climate/1783.json

Large diffs are not rendered by default.

217 changes: 8 additions & 209 deletions codes/climate/3001.json

Large diffs are not rendered by default.

548 changes: 548 additions & 0 deletions codes/climate/3101.json

Large diffs are not rendered by default.

968 changes: 968 additions & 0 deletions codes/climate/3102.json

Large diffs are not rendered by default.

294 changes: 294 additions & 0 deletions codes/climate/3400.json

Large diffs are not rendered by default.

251 changes: 251 additions & 0 deletions codes/climate/3500.json

Large diffs are not rendered by default.

406 changes: 406 additions & 0 deletions codes/climate/6686.json

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions codes/fan/1181.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"manufacturer": "Argo",
"supportedModels": ["Polifemo"],
"supportedController": "Broadlink",
"commandsEncoding": "Base64",
"speed": ["low", "medium", "high"],
"commands": {
"off": "JgBIAAABJpMTEhETExERFBESExEUERETEhITERI3EjgSNxI4EjcSNxITERMSEhEUERISExESEjgSNxI3EzcSNxM2EjYUNxISEwANBQ==",
"default": {
"low": "JgBIAAABJZMSExETEhMRExESEhMSEhISEhITEhE4EzYTNhI4ETgSNhMUEBMROBMRExETEhITETcTNxE4EhISNxI4EjcSNxISEgANBQ==",
"medium": "JgBIAAABJZMSExETEhMRExESEhMSEhISEhITEhE4EzYTNhI4ETgSNhMUEBMROBMRExETEhITETcTNxE4EhISNxI4EjcSNxISEgANBQ==",
"high": "JgBIAAABJZMSExETEhMRExESEhMSEhISEhITEhE4EzYTNhI4ETgSNhMUEBMROBMRExETEhITETcTNxE4EhISNxI4EjcSNxISEgANBQ=="
}
}
}
22 changes: 22 additions & 0 deletions codes/light/1000.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"manufacturer": "Iris Ohyama",
"supportedModels": ["LEDHCL-R2"],
"supportedController": "Broadlink",
"commandsEncoding": "Base64",
"brightness": [26, 51, 77, 102, 128, 153, 179, 204, 230, 255],
"colorTemperature": [
2700, 3122, 3544, 3967, 4389, 4811, 5233, 5656, 6078, 6500
],
"commands": {
"on": "JgACAbUfMhAQEQ8REBEQERAQEBEQETAREBEQEBAREBEQEBARMRAQERAREBEPERAREBEPERAREg8QEBAREBEPERAREBEQEBARMRAQETEQMRERDzERMBEQAAEntCAyDxAREBEQEQ8REBEQEQ8RMREPERAREBEPERAREBEwERAREBAQERAREBAQERAREBAQEREQEBEPERAREBEPERAREBEwERARMBExEBARMRAxERAAASa1IDEQEBEQEBAREBEQEBAREBEwERAREBEPERAREBEPETERDxEQERAREBAQERAREBAQERAREBAQERAREQ8QEREQEBAQETERDxExETAREBEwETEQEAANBQ==",
"off": [
"JgAEAT8ith4yDxAREBEQEBAREBEQEQ8RMREPERAREBEPERAREBEQEBARERAwERAREBAQERAREBAQEREQEBEPERAREBEPERAREBEwETEQMREwERARMBEQERAAASa1IDEQEBEQEBAREBEQEBAREBEwERAREBEPERAREBEPEREQEBEPETERDxEQERAREBAQERAREBAQERAREBAQERAREBAQETERMBEwETIQEBAxEQ8REAABJ7YeMhAPERAREBEPEREQEBEQEDEREBAREBAREBAQERAREBAQERARMBEQERARDxEREBEQDxEQERAREBAQERAREBAQERARMBExEDERMBEQETAREBEQAA0F",
"JgAEAUAgsyExEg8QEBEQEg8QEBEREBAQMRERDxEQEBEQETERDxEQEBARERAQEBEQEBEQEQ8REg8REA8REBEQEQ8REBERDxARERAwERARMBExETIPMRAQERAAASa0ITEQERAQERAQERAQERAQEBExEBEQERAQEBEQMRAQERAREBEQEBAREBEQEBAREBEQEBAREBEQEBEQEBEQEBASDxEQEDIQEBAyEDERMRAxEBAREAABJrMhMhEPEQ8REBEREA8REBEREDEQERAQEBAREBExEBEQEBAQEREQERAPEREQERAPEREQERAPERERDxEQEBAREBERDxARMRAQETIQMRAxEDIPERARAA0F"
],
"brighten": "JgAEAUMgtCAyDxARERAQEBARERAQERAQMREPEREQEBEPERARERAQEBEQERAQEBARMRAQERAREBAQERAREQ8QERAREBEQEBAREBExEBARMRAREBAQMREQEBEAASa0IDIQDxEREBAREBAQEREQEBAxEREPERAQEREPEBEQERAREBAREBAREBAyEBAQEBEQERAQERAQERAQEBEREBAQEBEQETEQERAwERAREBExEBAREAABJrUfMhAQEQ8RERAREBAQEBEQETEQEBERDxARERAQEBAREBEQEBARERAREDAREBEPERAREBEPERAREBEQEBAREBEQEBARMRAREDEQERAQETEQERARAA0F",
"dim": "JgAEAUAhtCAxEBAREBEREBAQERAREBAQMREQEBARERARDxAREBEQEDIQEQ8REBAREQ8QEREQEBAREBARERAPERARERAPEREQMBExERAQMRExEBARMRAQEREAASW1IDEQEBEQEBAREBERDxAREBEwERARERAPEREQEBEQEBARMRAREBAREBAREBAREBAREBAREBAQEREQEQ8REBAREQ8yEDEQERAyDzEREBAxERAQEQABJrMhMhAQEBEQEBEQEBAREBEQEDEREBAREBEQEQ8QEREQERAxEBARDxEQEREQEQ8QEREQEBAQERAREBAREBEQEBAREDEQMREQETEQMBEQETARERAQAA0F",
"colder": "JgAEAUAgtCAyDxEQERARDxIPERAREBAQMhARDxEQERARDxEQERARDxEQERARDzIQEQ8SDxEQEQ8REBEQEBEQEBEQERARDxEQERAxEBEQEQ8yEBEPMhEQDxEAASa0IDIQEBAREBEQEBAREBEQEQ8yEBEPERAQEREQEBAREBEQEBAQEREQMRAREBAQERAREBAQEBEREBAQERAREBEPERAREDEQERAREDEQERAwERAREAABJrUgMRAREA8REBEREBAQERAREDARERARDxARERARDxARERAQEBARERAwEREQERAQEBEQERAQEBEQERAQEBEQERAQEBARMRAREBEQMBEQETEQEBEQAA0F",
"warmer": "JgAEAUAgtSAxEBAREQ8REBEQEQ8SDxEQMRAQERAREBAREBEQEBAREBARMBEREBAQEBEREBEPEBEREBEPEBEQERAQERAQEREQDxEREBARMRAwERARMg8REBAAASa0ITARERAREBAQERAQERAQERAyDxEQERAQEBEQERARDxEQEBEyDxAREBEPERARERAQEBEQERAQEBARERAQEBEQERAQEBEQEBEyDzEQEg8xERAQEQABJrMhMhAPEREQEBEPEREQEBEPETIQEBAREBEQEQ8REBAREQ8REDEQERAREBAQEBEQERAREBAQEREQEBAREBEQDxEREBEQEBAQETEQMhAQEDIQEBARAA0F",
"night": "JgAEAUAhtCAyEBAQERAREA8RERAREBEPMhARDxARERARDxEQMg8REBEQEQ8REBEQEBAREBEQERAQEBEQERAQEBEQEBEQEBEQEBExEBEQMRAyDxEQERAQEBEAASa0IDIQEBAQEREQEBAQEREQERAxEBEQEBAREBEQEBAxERAQERAREBAQERAQERAQERAREBAQEBEREBEPERAREBEQEBAQETEQEBExEDIQEBAREBEQEQABJbUgMRAREBAQEBEREBEPERAQETEQERARDxARERARDzIQEBEQEBARERAQEBEQERAPEREQERAQEBEQERAQEBEQERAQEBEQMRAREDIPMhAQERAQERARAA0F"
}
}
17 changes: 17 additions & 0 deletions codes/light/1020.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"manufacturer": "NEC",
"supportedModels": ["RE0201-CH1"],
"supportedController": "Broadlink",
"commandsEncoding": "Base64",
"brightness": [26, 51, 77, 102, 128, 153, 179, 204, 230, 255],
"commands": {
"on": "JgBIAAABJ5QTEhI4EhMTEhMSExITEhM3EzcTEhM3EzgSExI4EjgSExM3ExITNxM3EzcTNxMTEjgSExI4EhMSExMSExITNxMSEwANBQ==",
"off": [
"JgBIAAABJpQTEhI4ExITEhMSExITEhM3EzcTExI4EjgSExI4FTUTEhM3ExITNxM3EzcTOBITEjgSExI4ExITEhMSExITNxMSEwANBQ==",
"JgBOAAABJ5QTEhI4EhMSExITExITEhM3EzcTEhM3EzcTExI4EjgSExITEjgTNxM3EzcTNxMSEzgSOBITEhMSExITExITNxMSEwAH6RYOEgANBQ=="
],
"brighten": "JgBYAAABKJMVERI4EhMSExITEhMSExI4EzcTEhM3EzcTEhM4EjgSExITEjgSExM3EzcTNxMSEzcTOBITEjgSExITEhMSOBMSEwAFYAABJkoSAAxYAAEmShIADQU=",
"dim": "JgBYAAABJpQUERM3ExITEhMSExMSExI4EjgSExM3EzcTEhM3EzcTEhM4EjgSExI4EzcTNxMSEzcTEhMSEzgSExITExISOBITEgAFYQABJkoSAAxYAAEnSRMADQU=",
"night": "JgBIAAABJpQTEhI4ExITEhMSExITEhM3EzcTEhM4EjgSExI4EzcTEhMSExITNxM3EzcTOBITEjgSOBM3ExITEhMSExITNxMSEwANBQ=="
}
}
17 changes: 17 additions & 0 deletions codes/light/1021.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"manufacturer": "NEC",
"supportedModels": ["RE0201-CH2"],
"supportedController": "Broadlink",
"commandsEncoding": "Base64",
"brightness": [26, 51, 77, 102, 128, 153, 179, 204, 230, 255],
"commands": {
"on": "JgBIAAABJ5QVEBI4EhMSExMSExITEhM3EzcTEhM3EzgSExI4EjgSExU1ExITNxM3EzcWNBMTEhMSExI4EhMSExMSExITNxM3EwANBQ==",
"off": [
"JgBIAAABJ5MUERM4EhMSExITEhMVEBI4EzcTEhM3EzcTEhM3EzgSExI4EhMSOBM3EzcTNxMSExITEhM4EhMSExITEhMSOBI4EwANBQ==",
"JgBIAAABJ5MUERM3ExMSExITEhMSExI4EjgTEhM3EzcTEhM3EzgSExITEjgSOBI4EzcTNxMSExITNxMTEhMSExITEhMSOBI4EwANBQ=="
],
"brighten": "JgBYAAABJ5MUERM3ExITExITEhMSExI4EjgSExM3EzcTEhM3EzcTEhMTEjgSExI4EjgTNxMSExITNxMSEzcTEhMTEhMSOBI4EgAFYAABJ0kTAAxUAAErSRMADQU=",
"dim": "JgBYAAABKpEVEBI4EhMTEhMSExITEhM3FjQTEhM4EjgSExI4EzcTEhM3EzcTEhM4EjgSOBITEhMSExMSEzcTEhMSExITNxM3EwAFYAABJ0kTAAxaAAElShIADQU=",
"night": "JgBIAAABJpQTEhM3ExITEhMSExITEhM3EzgSExI4EjgTEhM3EzcTEhMSExITOBI4EjgSOBMSExITNxM3ExITEhMSExMSOBI4EgANBQ=="
}
}
22 changes: 22 additions & 0 deletions codes/light/1040.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"manufacturer": "Toshiba",
"supportedModels": ["FRC-199T"],
"supportedController": "Broadlink",
"commandsEncoding": "Base64",
"brightness": [
16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240, 255
],
"colorTemperature": [
2700, 2953, 3207, 3460, 3713, 3967, 4220, 4473, 4727, 4980, 5233, 5487,
5740, 5993, 6247, 6500
],
"commands": {
"on": "",
"off": ["", ""],
"brighten": "",
"dim": "",
"colder": "",
"warmer": "",
"night": ""
}
}
25 changes: 25 additions & 0 deletions codes/light/1060.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"manufacturer": "Takizumi",
"supportedModels": ["TLR-002"],
"supportedController": "Broadlink",
"commandsEncoding": "Base64",
"brightness": [
16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240, 255
],
"colorTemperature": [
2700, 2953, 3207, 3460, 3713, 3967, 4220, 4473, 4727, 4980, 5233, 5487,
5740, 5993, 6247, 6500
],
"commands": {
"on": "JgDYAAABKY8UERMRFDUUEBQRExITEBQ1FBETNhISFBEROBQQFDUSExMRFDUUEBQREzYUNRITExETNhQQFDYTNhQQFBETNhQ1FAAFoAABKpATERQQFDUUERMRFBAUEBQ2ExEUNRQRERMTNhQQFDYRExQQFDUUERMRFDUSOBMRExEUNRQREzYTNhITExETNhQ1FAAFoAABJ5MTERQQFDYTERQQFBAUERM2FBAUNRQRExEUNRQREzYUEBQQFDYTERQQFDUUNhQQFBAUNhMRFDUUNhMRFBAUNRQ2FAANBQ==",
"off": [
"JgAYAwABJpMVDxQREzYUEBQQFBEUEBM2FBAUNhQQFBAUNRQREzYUEBQQFDYUEBQQFDYTNhQQFBAUNhQQFDUUNhMRFBAUNRQ2EwAFoAABJ5MUEBQQFDYUEBQQFBAUERM2FBAUNhMRExEUNRQQFDYUEBQQFDYTERQQFDUUNhMRFBAUNRQRFDUUNRQRExEROBU0FAAFoAABKZEUEBQQFDUUERMRFBAUEBI4ExEUNRQQFBETNhQQFDUVEBQQEjcUEBQREzYUNRUQExEUNRQQFDYUNRQQFBAUNhQ1FQAFngABJ5MUEBQREzYUEBQQFBETERQ1FBAUNhMRFBAUNhMRFDUUEBQREzYUEBQQFDYTNhQQFBETNhQQFDUUNhMRFBAUNRQ2EwAFoAABJ5MSEhQREzYTERQQFBAUERM2FBAUNRQRExEUNRQREzYTERQQFTUTERQQFDUUNhMRFBETNhMREzYUNRITExESNxQ1FAAFoQABJpMTERMRFDUUERMREhIUEBQ2EhIUNRQQFBETNhISFDYTERMSEzUUERMREzYUNRQRExEUNRQQFDYUNRQQFBETNhQ1FAAFoAABJpMUERMRFDUUEBQRExEUEBQ1FBETNhMRFBAUNhMRFDUUERMREzYUEBQQFDYTNhQQFBEROBMRFDUUNhMRFBAUNhM2EwAFoQABJpMTERQQFDYTEhMQFBETERQ1FBAUNhMRFBAUNRQREzYTERQQFDYTERQREzYTNhMRFBASOBMRFDUSNxITExEUNRQ2EwAFoAABKZESEhQQFDUSExMRFBETEBQ2ExITNRITExESNxQREzYTERMRFDUUERMRFDUSOBMRExEUNRITEzYSNxQQFBETNhI3EgAFogABKZASExMREzYUEBQRExETERQ1FBETNhITExETNhISEzYSExMREzYSEhQREzYSNxITExETNhISFDYROBISExEUNhE4EgAFogABKJESEhQREzYSEhQQFBERExM2FBAUNhETExITNRITEzYSEhQREzYTEhMREzYROBISExEUNhEUEjYSOBETExESNxI4EgANBQ==",
"JgDYAAABJZMUEBISEjgSEhISEhISExE4FBASOBMREhISNxQRETgUEBITERMROBM2EzcROBQ1FBESNxQ1FBERExETEhISExE4EgAFogABKJIVDxISEjgTERISEhISExE4FBATNhMSERMSNxMREzcUEBISExIROBM2EzcTNhI3FBASOBQ1FBATEhETEhISEhI4FAAFoAABJ5MTERISEjcUERETEhISEhI4EhISNxMRExIROBQQEjgRExISEhISOBI3FTQSOBM2FBASOBM2FBASEhITERMSEhI3EwANBQ=="
],
"brighten": "JgDYAAABJpMUEBISEjgSEhISEhISExE4ExESOBISEhISNxMSETgTERISEhMRExISEjcTEhE4ExESOBI3EzYVNRISEjcTERI4EwAFoQABKJEVEBISEjcVEBETEhISEhI4ExESNxMREhMROBMREjgSEhISEhISExETETgTERI4EhISNxM3ETgUNRUPEjgTERI3EwAFoQABJ5MVDxITETgTERISEhMRExI3ExESOBISEhISOBETEjcTERITERMSEhISEjgUEBI3ExESOBE4EzYVNRISEjcTEhE4EwANBQ==",
"dim": "JgCQAAABJ5ESEhITETgSEhISEhMRExE4EhISOBETEhISNxITETgSEhITERMROBISEjgROBI3EhMROBI3EhMROBISEhISExE4EgAFoQABKZESExETEjcSEhITERMSEhI3EhMROBISEhISOBISEjcSExETEhISNxITETgSNxI4ERMSNxI4ERMSNxISEhMRExI3EgANBQ==",
"colder": "JgAgAQABJZMVDxQQFDYUEBQQFBETERE4FBAUNhQQFBAXMxMRFDUUEBQQFBETNhQQFBETERQ1FBAUNhQ1FBAUNhI3EzYUERQ1EwAFoQABJpMVEBMRFDUUERMRExEUERM2ExETNxMQFBETNhMRFDYTERMRFBAUNhMRExEUERM2ERQSNhI4ExETNhQ1EjgSEhM2EgAFogABKZESEhQREzYTEhMRExETERM2EhMTNhITEhITNhETEzYSExMRExETNhITExETERM2EhMTNhI3EhIUNhE4EzYSExE4EgAFogABKZESEhMSEzUSExMRExEUERM2ERQSNhITExETNhMRFDYRExMRFBETNhETExITEBQ2ExETNhI4ERMTNhI4ETgSEhQ1EgANBQ==",
"warmer": "JgDYAAABJ5ERExISEjcSExETEhISEhI4ERMSNxITERMROBISEjgRExISEhMRExMREhITNhI4ERMSNxI4ETgSNxI4ERMSEhI3EgAFowABKZASEhISEjgRExISEhMRExM2EhISOBETEhITNhITETgSEhITERMRExMRExEUNhE4EhISOBE4EjcSOBE4EhISEhI4EgAFoQABKZESEhITEzYSEhQRExETERQ1FBETNhISEhIUNhETEzYSExMRExEUEBQRExETNhI3EhMTNhI3EjgROBI3EhMTERM2EwANBQ==",
"night": "JgDYAAABJpISExETEjcSExETERMSEhI4ERMROBISEhMROBISEjcSExETEhISEhI4EjcSEhI4ERMSNxI4ETgSEhISEjgRExI3EgAFoQABKpESExETETgSEhITERMSEhI3EhMROBITERMROBISEjcSExETEhISEhI4ETgSEhI4ERMROBI4ETgSEhISEjgRExI3EgAFowABKZASEhITETgSEhITERMRFBE3EhMROBISEhISOBETEjcSEhITERMSEhM2EjgSEhI3EhMROBI3EjgRExISEjcSExE4EgANBQ=="
}
}
27 changes: 27 additions & 0 deletions custom_components/smartir/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ async def check_file(file_name, device_data, device_class, check_data):
file_name, device_data, device_class, check_data
):
return True
elif device_class == "light":
if DeviceData.check_file_light(
file_name, device_data, device_class, check_data
):
return True
return False

@staticmethod
Expand Down Expand Up @@ -532,6 +537,11 @@ def check_file_fan(file_name, device_data, device_class, check_data):
def check_file_media_player(file_name, device_data, device_class, check_data):
return True

@staticmethod
def check_file_light(file_name, device_data, device_class, check_data):
return True

# round to given precision
@staticmethod
def precision_round(number, precision):
if precision == 0.1:
Expand All @@ -544,3 +554,20 @@ def precision_round(number, precision):
return round(float(number) / int(precision)) * int(precision)
else:
return None

# find the closest match in a sorted list
@staticmethod
def closest_match(value, list):
prev_val = None
for index, entry in enumerate(list):
if entry > (value or 0):
if prev_val is None:
return index
diff_lo = value - prev_val
diff_hi = entry - value
if diff_lo < diff_hi:
return index - 1
return index
prev_val = entry

return len(list) - 1
Loading

0 comments on commit aff94b8

Please sign in to comment.