npope / home-assistant-crestron-component

Integration for Home Assistant for the Crestron XSIG symbol
Apache License 2.0
59 stars 20 forks source link

Analog signal can not be switched on or off in HA when changed from zero at the Crestron end #1

Closed jmayes2 closed 3 years ago

jmayes2 commented 3 years ago

First off I love this integration!!! Hats off to you!!

I have nailed down a repeatable process I think you need to be aware of.

When controlling an analog signal after it's set to off in HA then the Crestron changes it to non-zero HA will no longer turn it on or off. You can adjust the brightness in HA and have full control again until you turn it off in ha and the Crestron makes a change on it's end.

Exact steps,

Turn off the analog signal with the on/off switch in HA then change the analog signal to non-zero in the Crestron, at this point the brightness slider in HA will properly show on and the value you set with the Crestron but the on/off switch in HA will not work until you move the brightness bar in HA or change the value to zero in the crestron.

Thankx again for a great utility! Jmayes

ikosa commented 3 years ago

i cant repeat the problem. It is working fine in my setup.

jmayes2 commented 3 years ago

After further investigation I have found that the xsig input and output need to be tied together in order turn an analog on or off, ie if the output is not at zero when you try to turn it on it won't work likewise if the output is not above zero it won't turn off. (regardless of what the inputs are at), I don't know why it needs the outputs at a expected state in order to send a command to them. It should just send another logic wave regardless of the outputs state. My main issue is I can not have the inputs and outputs tied together as it creates a feedback loop in my program. I made a work around to use a buffer/osc to synchronize the outputs with the inputs every 3 seconds but now I find lights sometimes will go back off after hitting the switch on the wall if I am at the exact time of the update taking place. If it would just send another logic wave regardless of output state it would be perfect. I hope this feedback helps, TX, J

jmayes2 commented 3 years ago

The picture has finally become clear, the problem is not in ikosa's code but with the Xsig symbol itself. As long as you can tie both the input and output of the Xsig symbol together there is no problem but if you need to keep them seperate (because of logic issues) things go bad. Both intersystem comm (Xsig) and buffer symbols in crestron will not reprogate a signal that is at the same level therefore if the output of the xsig (analog join) is already at 0% another off command will not make a change or send another logic wave (same for 100% or any exact %). Same issue on a switch (digital join). The problem is that if the crestron program has changed the state of the controlled device (which feedback confirms correctly to ha), the output of xsig will remain at the last state. Say the light was turned on by HA and the Xsig output is now at 100%, then the crestron program turns off the light, feedback changes to 0% but the output of the Xsig is still 100%. You try to turn on the light back on with HA and nothing happens because the output is already 100%. If you monitor the serial from HA to Xsig you will see the on signal is being transmitted, just no change to the xsig output as per the above explanation.

I finally found a work around, use a serial i/o symbol and let it sniff the data from HA and you can achieve on/off pulses which can feed an analog initialize to send (or resend) analog on/off's. This does not fix the case if some lamp is at 58% and gets turned off and is then told to go to 58% again by HA (as the output of Xsig would already be at 58%) but going to exact percentages is a rare case and I am just being complete here to mention this caveat. If you think this will be an issue then you can use serial to analog symbols and take exact %'s.

The RX from HA is easy to decode, 4 bytes for analog and 2 bytes for digital. The 2nd byte is the join# (used in the yaml) -1 in hex. In the case of digital the 1st byte, off is \x80 and on is \xC0. Analog bytes 3&4 are 00-7F added together make 0-65535d. I only need to trap on and off which make both bytes \x00 or \x7f. The 1st byte for analog is \xC0 to \xF0 which can be ignored (not sure why this one is sent). So for instance if you want to get the 1st analog "off" you would look for 4 bytes \xC0\x00\x\00\x00 and 100% is \xF0\x00\x7F\x7F. for digital starting as the 2nd device would be \x80\x01 for off and \xC0\x01 for on. A simple+ routine would also be an option to replace the Xsig all together.

Ikosa, I totally compliment you for this great code! Without it I would not be able to meld HA to my Crestron setup and now together it makes the most powerful HA setup ever!!!

Thankx again, J

jmayes2 commented 3 years ago

HA_Crestron-example1