@@ -68,7 +68,7 @@ def handleCommonGesture(self, event):
6868
6969 # Special handling for TOGGLE: Resolve state first to be able showing the correct action icon
7070 if command == "TOGGLE" :
71- state = requests . get ( self .openhab .base_url + "/items/" + widget ["item" ]["name" ] + "/state" ). text
71+ state = self .openhab .get_item ( widget ["item" ]["name" ]). state
7272 if state in config ["toggle_mapping" ]:
7373 command = str (config ["toggle_mapping" ][state ])
7474 elif state == "NULL" and widget ["item" ]["type" ] in config ["initial_command" ]:
@@ -119,17 +119,18 @@ def handleSliders(self, rotationOffset):
119119 # Take care that the slider status shown on the LED matrix
120120 # and used for calculating the new slider state is not older than 3s
121121 self .openhab .req_post ("/items/" + widget ["item" ]["name" ], "REFRESH" )
122- logging .debug (self .openhab .base_url + widget ["item" ]["name" ] + "/state" )
123- itemStateRaw = requests .get (self .openhab .base_url + "/items/" + widget ["item" ]["name" ] + "/state" ).text
124- if (itemStateRaw == "NULL" ):
125- itemStateRaw = config ["initial_command" ]["Dimmer" ]
126- currentState = float (itemStateRaw )
122+ logging .debug ("New Rotation Action" + widget ["item" ]["name" ] + "/state" )
123+ item = self .openhab .get_item (widget ["item" ]["name" ])
124+ if (item .is_state_null () or item .is_state_undef ()):
125+ currentState = config ["initial_command" ]["Dimmer" ]
126+ else :
127+ currentState = float (item .state )
127128 if currentState <= 0 :
128129 currentState = 0
129130 elif currentState < 1 :
130131 currentState *= 100
131132 self .lastSliderState = int (currentState )
132- logging .debug ("Raw item state : " + itemStateRaw )
133+ logging .debug ("Item State : " + str ( item . state ) )
133134
134135 if abs (self .reminder ) >= 1 :
135136 logging .debug ("Old state: " + str (self .lastSliderState ))
0 commit comments