From d1dc2157ddceb267fcc5880c2eab2ea02475e832 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccolo=CC=80=20Zapponi?= Date: Sat, 5 Sep 2020 15:55:29 +0100 Subject: [PATCH 1/2] Added support for non dimmable light bulbs with Shelly Dimmer --- custom_components/shelly/__init__.py | 3 +++ custom_components/shelly/const.py | 1 + 2 files changed, 4 insertions(+) diff --git a/custom_components/shelly/__init__.py b/custom_components/shelly/__init__.py index 24ddf1e..a4ff2ba 100755 --- a/custom_components/shelly/__init__.py +++ b/custom_components/shelly/__init__.py @@ -491,6 +491,9 @@ async def _async_device_added(self, dev, _code): elif dev.device_type == "BINARY_SENSOR": self.add_device("binary_sensor", dev) elif dev.device_type in ["LIGHT", "DIMMER", "RGBLIGHT"]: + dimmable = True + if device_config.get(CONF_DIMMER_DIMMABLE) === False: + dev.device_type = "RELAY" self.add_device("light", dev) else: _LOGGER.error("Unknown device type, %s", dev.device_type) diff --git a/custom_components/shelly/const.py b/custom_components/shelly/const.py index a8e4e57..6fa8e6d 100644 --- a/custom_components/shelly/const.py +++ b/custom_components/shelly/const.py @@ -24,6 +24,7 @@ CONF_IGMPFIX = 'igmp_fix' CONF_MDNS = 'mdns' CONF_LIGHT_SWITCH = 'light_switch' +CONF_DIMMER_DIMMABLE = 'dimmable' CONF_OBJECT_ID_PREFIX = 'id_prefix' CONF_ENTITY_ID = 'entity_id' CONF_SHOW_ID_IN_NAME = 'show_id_in_name' From df0da4e093f6ec7ac6356ea9c99f2b0baa8c8dbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccolo=CC=80=20Zapponi?= Date: Sat, 5 Sep 2020 16:41:23 +0100 Subject: [PATCH 2/2] Added support for non-dimmable bulbs with Shelly Dimmer 2 --- README.md | 1 + custom_components/shelly/__init__.py | 3 +-- custom_components/shelly/configuration_schema.py | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a683a2a..eb5a45f 100644 --- a/README.md +++ b/README.md @@ -253,6 +253,7 @@ shelly: | name | Specify if you want to set a name of the device | My Cool Shelly | | | entity_id | Override the auto generated part of entity_id, like shsw_1_500500 | bedlamp | 0.0.16- | | light_switch | Show this switch as a light | True | | +| dimmable | Show this dimmer as a dimmable light (set to false for non-dimmable bulbs) | True | | | sensors | A list with sensors to show for each device. This will override the global sensors. See list below. | | 0.0.15- | | upgrade_switch | Add firmware switches when upgrade needed. Override global configuration. | False | 0.0.15- | | unavailable_after_sec | Overide number of seconds before the device will be unavialable. | 120 | 0.0.16- | diff --git a/custom_components/shelly/__init__.py b/custom_components/shelly/__init__.py index a4ff2ba..ab56017 100755 --- a/custom_components/shelly/__init__.py +++ b/custom_components/shelly/__init__.py @@ -491,8 +491,7 @@ async def _async_device_added(self, dev, _code): elif dev.device_type == "BINARY_SENSOR": self.add_device("binary_sensor", dev) elif dev.device_type in ["LIGHT", "DIMMER", "RGBLIGHT"]: - dimmable = True - if device_config.get(CONF_DIMMER_DIMMABLE) === False: + if device_config.get(CONF_DIMMER_DIMMABLE) == False: dev.device_type = "RELAY" self.add_device("light", dev) else: diff --git a/custom_components/shelly/configuration_schema.py b/custom_components/shelly/configuration_schema.py index b3d528f..45a11d7 100644 --- a/custom_components/shelly/configuration_schema.py +++ b/custom_components/shelly/configuration_schema.py @@ -38,6 +38,7 @@ vol.Required(CONF_ID): cv.string, vol.Optional(CONF_NAME): cv.string, vol.Optional(CONF_LIGHT_SWITCH, default=False): cv.boolean, + vol.Optional(CONF_DIMMER_DIMMABLE, default=True): cv.boolean, vol.Optional(CONF_SENSORS): vol.All(cv.ensure_list, [vol.In(ALL_SENSORS_W_EXTRA)]), vol.Optional(CONF_UPGRADE_SWITCH): cv.boolean,