mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 17:27:10 +00:00
Make Appliance Type Case-insensitive (#43114)
"appliance_type" is a free text parameter in the device settings, this fix will make the comparison case-insensitive
This commit is contained in:
parent
be93060e99
commit
22a0464dce
@ -30,18 +30,18 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||||||
for block in wrapper.device.blocks:
|
for block in wrapper.device.blocks:
|
||||||
if block.type == "light":
|
if block.type == "light":
|
||||||
blocks.append(block)
|
blocks.append(block)
|
||||||
elif (
|
elif block.type == "relay":
|
||||||
block.type == "relay"
|
appliance_type = wrapper.device.settings["relays"][int(block.channel)].get(
|
||||||
and wrapper.device.settings["relays"][int(block.channel)].get(
|
|
||||||
"appliance_type"
|
"appliance_type"
|
||||||
)
|
)
|
||||||
== "light"
|
if appliance_type and appliance_type.lower() == "light":
|
||||||
):
|
blocks.append(block)
|
||||||
blocks.append(block)
|
unique_id = (
|
||||||
unique_id = f'{wrapper.device.shelly["mac"]}-{block.type}_{block.channel}'
|
f'{wrapper.device.shelly["mac"]}-{block.type}_{block.channel}'
|
||||||
await async_remove_entity_by_domain(
|
)
|
||||||
hass, "switch", unique_id, config_entry.entry_id
|
await async_remove_entity_by_domain(
|
||||||
)
|
hass, "switch", unique_id, config_entry.entry_id
|
||||||
|
)
|
||||||
|
|
||||||
if not blocks:
|
if not blocks:
|
||||||
return
|
return
|
||||||
|
@ -23,18 +23,21 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||||||
|
|
||||||
relay_blocks = []
|
relay_blocks = []
|
||||||
for block in wrapper.device.blocks:
|
for block in wrapper.device.blocks:
|
||||||
if block.type == "relay" and (
|
if block.type == "relay":
|
||||||
wrapper.device.settings["relays"][int(block.channel)].get("appliance_type")
|
appliance_type = wrapper.device.settings["relays"][int(block.channel)].get(
|
||||||
!= "light"
|
"appliance_type"
|
||||||
):
|
|
||||||
relay_blocks.append(block)
|
|
||||||
unique_id = f'{wrapper.device.shelly["mac"]}-{block.type}_{block.channel}'
|
|
||||||
await async_remove_entity_by_domain(
|
|
||||||
hass,
|
|
||||||
"light",
|
|
||||||
unique_id,
|
|
||||||
config_entry.entry_id,
|
|
||||||
)
|
)
|
||||||
|
if not appliance_type or appliance_type.lower() != "light":
|
||||||
|
relay_blocks.append(block)
|
||||||
|
unique_id = (
|
||||||
|
f'{wrapper.device.shelly["mac"]}-{block.type}_{block.channel}'
|
||||||
|
)
|
||||||
|
await async_remove_entity_by_domain(
|
||||||
|
hass,
|
||||||
|
"light",
|
||||||
|
unique_id,
|
||||||
|
config_entry.entry_id,
|
||||||
|
)
|
||||||
|
|
||||||
if not relay_blocks:
|
if not relay_blocks:
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user