@@ -68,7 +68,7 @@ def handleCommonGesture(self, event):
68
68
69
69
# Special handling for TOGGLE: Resolve state first to be able showing the correct action icon
70
70
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
72
72
if state in config ["toggle_mapping" ]:
73
73
command = str (config ["toggle_mapping" ][state ])
74
74
elif state == "NULL" and widget ["item" ]["type" ] in config ["initial_command" ]:
@@ -119,17 +119,18 @@ def handleSliders(self, rotationOffset):
119
119
# Take care that the slider status shown on the LED matrix
120
120
# and used for calculating the new slider state is not older than 3s
121
121
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 )
127
128
if currentState <= 0 :
128
129
currentState = 0
129
130
elif currentState < 1 :
130
131
currentState *= 100
131
132
self .lastSliderState = int (currentState )
132
- logging .debug ("Raw item state : " + itemStateRaw )
133
+ logging .debug ("Item State : " + str ( item . state ) )
133
134
134
135
if abs (self .reminder ) >= 1 :
135
136
logging .debug ("Old state: " + str (self .lastSliderState ))
0 commit comments