I have found that slider values, as reported via the websocket sometimes do not match the actual state.
This is my relay control (main 24V on/off):
var power24v = 26
pinMode(power24v,OUTPUT)
export var relay_status = digitalRead(power24v)
export function sliderRelay(x) {
digitalWrite(power24v, (x > 0.5))
relay_status = digitalRead(power24v)
}
So I can read the variable relay_status
to tell if the relay is on or not, and use sliderRelay
to turn it on and off.
The problem comes when I change the relay setting via websocket, the relay_status
changes, but the UI does not, and neither does the sliderRelay
value.
I get results like this:
[2021-05-14 14:52:46,388][ INFO](Pixelblaze.PixelblazeBase.Pixelblaze_79C309) publishing item: LED_Controller/pixelblaze/update: {"vars":{"relay_status":1,"masked":1,"r":0,"g":0,"b":0}}
[2021-05-14 14:52:46,484][ INFO](Pixelblaze.PixelblazeBase.Pixelblaze_79C309) publishing item: LED_Controller/pixelblaze/update: {"activeProgram":{"name":"Blank","activeProgramId":"ShzpfL53tXQDBLbRv","controls":{"sliderRelay":0}},"sequencerMode":0,"runSequencer":false}
If I change sliderRelay
in the UI, the value changes, but not by sending
{'setControls': {'sliderRelay': 1}, 'save': False}
What I’m looking for is for the UI and value of controls to reflect the actual state of the control, when it is updated via the websocket. I have a feeling it’s to do with the 'save': False
, because if I try with 'save': True
it seems to work (ie the value changes, but the UI still does not). I don’t want to change the default every time I set the relay On/Off though.
So I think if you read the setting of controls, it’s not reporting the actual setting, but the saved setting - which for the UI is the same, but not if you change it via websocket (without save: True
).
Not sure how to get the UI to update and reflect the actual setting either.
Any other suggestion for how to do this? otherwise the UI and websocket interface gets out of sync, and while it doesn’t really matter for speed etc, with Main Relay On/Off it’s kind of crucial to know what it actually is.
Thanks.