npope / home-assistant-crestron-component

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

Digitals getting out of sync between Crestron and HA #13

Open natethelen opened 1 year ago

natethelen commented 1 year ago

I am wondering if anyone else has seen this problem and if so, what you have done to deal with it. I am using a media player mute for the example but this happens with any digital.

My setup:

Crestron-side Intersystem Communications
mute_on_fb        dig_in100        dig_out100       mute_control

HA-side Config
media_player:
  - platform: crestron
    mute_join: 100
    ... other values for media_player

The problem happens when you control a digital from both sides. Sometime you interact with a Crestron interface, sometimes a HA interface. This can happen for example if your remote control is integrated with Crestron but on your phone you only use HA. Before the process below someone has muted and unmuted on Crestron and another time someone has muted and unmuted on HA. Everything is fine as long as you do both the mute and the unmute on one side or the other. The problem occurs when you do one on Crestron then try to do the other on HA. For example:

Crestron State (Currently Unmuted):

mute_on_fb: 0
mute_control: 0

Press Mute in Crestron, New Crestron State:

mute_on_fb: 1
mute_control: 0

Press Mute in HA. Nothing happens. No change in Crestron's state. If you turn on debug logging in the crestron add-on on the HA side you will see that it sent a mute_control of 0 to Crestron but since the Crestron mute_control value was already 0, Crestron didn't do anything with it, never bubbling the event up to anything the program knows about.

The solution I have put into place is to change the value of the mute_control to be the feedback. This works in any case that you have discrete controls (a "turn mute on" AND a "turn mute off"), but if you only can toggle, this won't work. Does anyone have thoughts as to the best way to handle this overall?

natethelen commented 1 year ago

Same thing happens to analogs.

Crestron-side Intersystem Communications
light_current_level        ain200        aout200       light_level

If you have a light level that is off (Crestron light_level = 0, light_current_level = 0), you turn it on in crestron (Crestron light_level = 0, light_current_level = 65535) , then try and turn it off in HA (setting light_level to 0 and sending to Crestron), nothing happens because from Crestron's point of view nothing has changed.

When I try setting light_level to light_current_level on the Crestron side, it works most of the time, but I run into flashing light problems, especially when doing dimming transitions.

My current solution on this one is to use a Analog Value Sample to propagate the light_current_level to the light_level every couple seconds but I am not completely satisfied as it introduces a delay on the HA side