@@ -30,20 +30,25 @@ async def async_setup_entry(
3030 _LOGGER .info ("switch: already added: " + str (stick .config ['devices' ]))
3131
3232 to_add : List [SwitchEntity ] = []
33- for duofernDevice in stick .config ['devices' ]:
34- duofernId : str = duofernDevice ['id' ]
35- subId = "manualMode"
36- if not is_shutter (duofernId ):
37- _LOGGER .info ("switch: skipping: " + str (duofernId ) + " because it is not a shutter" )
38- continue
39-
40- if isDeviceSetUp (hass , duofernId , subId ):
41- _LOGGER .info ("switch: skipping: " + str (duofernId ) + " because it is is already set up" )
42- continue
4333
44- switch = DuofernShutterConfigurableSwitch (duofernId , stick , "manualMode" , "Manual Mode" , "manual_mode" )
45- to_add .append (switch )
46- saveDeviceAsSetUp (hass , switch , duofernId , subId )
34+ shutterSwitches = {
35+ "manualMode" : ["manualMode" , "Manual Mode" , "manual_mode" ],
36+ "sunAutomatic" : ["sunAutomatic" , "Sun Automatic" , "sun_automatic" ]
37+ }
38+ for subId , [command , nameSuffix , idSuffix ] in shutterSwitches .entries ():
39+ for duofernDevice in stick .config ['devices' ]:
40+ duofernId : str = duofernDevice ['id' ]
41+ if not is_shutter (duofernId ):
42+ _LOGGER .info ("switch: skipping: " + str (duofernId ) + " because it is not a shutter" )
43+ continue
44+
45+ if isDeviceSetUp (hass , duofernId , subId ):
46+ _LOGGER .info ("switch: skipping: " + str (duofernId ) + " because it is is already set up" )
47+ continue
48+
49+ switch = DuofernShutterConfigurableSwitch (duofernId , stick , command , nameSuffix , idSuffix )
50+ to_add .append (switch )
51+ saveDeviceAsSetUp (hass , switch , duofernId , subId )
4752
4853 async_add_entities (to_add )
4954
0 commit comments