Lakritzator / harmony

C# library for connecting to and controlling the Logitech Harmony Hub.
MIT License
5 stars 0 forks source link

Add activity change events #5

Open Lakritzator opened 8 years ago

Lakritzator commented 8 years ago

When changing the activity and monitoring the messages send by the harmony hub, I can see the following.

This should be processed, to generate events.

<message xmlns="jabber:client" content-length="215" />
<message xmlns="jabber:client" from="HarmonyOne_Pop@qa1.com" to="xxxxxxxxxxxxxxxxxxxx"><event xmlns="connect.logitech.com" type="vnd.logitech.control/vnd.logitech.button?pressType"><![CDATA[type=short]]></event></message>
<message xmlns="jabber:client" content-length="719" />
<message xmlns="jabber:client" from="HarmonyOne_Pop@qa1.com" to="xxxxxxxxxxxxxxxxxxxx"><event xmlns="connect.logitech.com" type="connect.stateDigest?notify"><![CDATA[{"sleepTimerId":-1,"configVersion":226,"activityId":"20780607","syncStatus":0,"time":1470561464,"stateVersion":1174,"tzOffset":"7200","mode":3,"hubSwVersion":"4.10.30","deviceSetupState":[],"tzoffset":"7200","isSetupComplete":true,"contentVersion":83,"wifiStatus":1,"discoveryServer":"http:\/\/svcs.myharmony.com\/Discovery\/Discovery.svc","activityStatus":1,"runningActivityList":"20780624","tz":"CET-1CEST,M3.4.0,M10.5.0\/3","activitySetupState":false,"updates":{"97":"4.10.30"},"hubUpdate":false,"sequence":false,"accountId":"7102919"}]]></event></message>
<message xmlns="jabber:client" content-length="215" />
<message xmlns="jabber:client" from="HarmonyOne_Pop@qa1.com" to="xxxxxxxxxxxxxxxxxxxx"><event xmlns="connect.logitech.com" type="harmony.engine?startActivity"><![CDATA[done=1:total=2:deviceId=29923832]]></event></message>
<message xmlns="jabber:client" content-length="215" />
<message xmlns="jabber:client" from="HarmonyOne_Pop@qa1.com" to="xxxxxxxxxxxxxxxxxxxx"><event xmlns="connect.logitech.com" type="harmony.engine?startActivity"><![CDATA[done=2:total=2:deviceId=36988229]]></event></message>
<message xmlns="jabber:client" content-length="719" />
<message xmlns="jabber:client" from="HarmonyOne_Pop@qa1.com" to="xxxxxxxxxxxxxxxxxxxx"><event xmlns="connect.logitech.com" type="connect.stateDigest?notify"><![CDATA[{"sleepTimerId":-1,"configVersion":226,"activityId":"20780607","syncStatus":0,"time":1470561464,"stateVersion":1175,"tzOffset":"7200","mode":3,"hubSwVersion":"4.10.30","deviceSetupState":[],"tzoffset":"7200","isSetupComplete":true,"contentVersion":83,"wifiStatus":1,"discoveryServer":"http:\/\/svcs.myharmony.com\/Discovery\/Discovery.svc","activityStatus":2,"runningActivityList":"20780624","tz":"CET-1CEST,M3.4.0,M10.5.0\/3","activitySetupState":false,"updates":{"97":"4.10.30"},"hubUpdate":false,"sequence":false,"accountId":"7102919"}]]></event></message>
<message xmlns="jabber:client" content-length="239" />
<message xmlns="jabber:client" from="HarmonyOne_Pop@qa1.com" to="xxxxxxxxxxxxxxxxxxxx"><event xmlns="connect.logitech.com" type="harmony.engine?startActivityFinished"><![CDATA[activityId=20780607:errorCode=200:errorString=OK]]></event></message>
<message xmlns="jabber:client" content-length="719" />
<message xmlns="jabber:client" from="HarmonyOne_Pop@qa1.com" to="xxxxxxxxxxxxxxxxxxxx"><event xmlns="connect.logitech.com" type="connect.stateDigest?notify"><![CDATA[{"sleepTimerId":-1,"configVersion":226,"activityId":"20780607","syncStatus":0,"time":1470561464,"stateVersion":1176,"tzOffset":"7200","mode":3,"hubSwVersion":"4.10.30","deviceSetupState":[],"tzoffset":"7200","isSetupComplete":true,"contentVersion":83,"wifiStatus":1,"discoveryServer":"http:\/\/svcs.myharmony.com\/Discovery\/Discovery.svc","activityStatus":2,"runningActivityList":"20780607","tz":"CET-1CEST,M3.4.0,M10.5.0\/3","activitySetupState":false,"updates":{"97":"4.10.30"},"hubUpdate":false,"sequence":false,"accountId":"7102919"}]]></event></message>
Lakritzator commented 8 years ago

I have X-ed out the to address, just in case...

Lakritzator commented 8 years ago

This now works, there is a

         public event EventHandler<string> OnActivityChanged;

On the HarmonyClient which informs you when the activity is changed, so when it's really active not while switching.

Lakritzator commented 8 years ago

Actually there still is an issue in the setActivity usage, this sends "100" responses and these should be ignored.

Lakritzator commented 8 years ago

When changing the activity the following messages are send:

<iq xmlns="jabber:client" to="1" id="agsXMPP_3" type="get"><oa xmlns="connect.logitech.com" errorcode="200" mime="vnd.logitech.harmony/vnd.logitech.harmony.engine?startactivity" errorstring="OK" /></iq>
<iq xmlns="jabber:client" id="agsXMPP_3" type="get"><oa xmlns="connect.logitech.com" errorcode="100" mime="harmony.engine?startActivity" errorstring="Continue"><![CDATA[done=1:total=10:deviceId=29923836]]></oa></iq>
<iq xmlns="jabber:client" id="agsXMPP_3" type="get"><oa xmlns="connect.logitech.com" errorcode="100" mime="harmony.engine?startActivity" errorstring="Continue"><![CDATA[done=2:total=10:deviceId=29923832]]></oa></iq>
<iq xmlns="jabber:client" id="agsXMPP_3" type="get"><oa xmlns="connect.logitech.com" errorcode="100" mime="harmony.engine?startActivity" errorstring="Continue"><![CDATA[done=3:total=10:deviceId=36988229]]></oa></iq>
<iq xmlns="jabber:client" id="agsXMPP_3" type="get"><oa xmlns="connect.logitech.com" errorcode="100" mime="harmony.engine?startActivity" errorstring="Continue"><![CDATA[done=4:total=10:deviceId=29923832]]></oa></iq>
<iq xmlns="jabber:client" id="agsXMPP_3" type="get"><oa xmlns="connect.logitech.com" errorcode="100" mime="harmony.engine?startActivity" errorstring="Continue"><![CDATA[done=5:total=10:deviceId=29923832]]></oa></iq>
<iq xmlns="jabber:client" id="agsXMPP_3" type="get"><oa xmlns="connect.logitech.com" errorcode="100" mime="harmony.engine?startActivity" errorstring="Continue"><![CDATA[done=6:total=10:deviceId=29923832]]></oa></iq>
<iq xmlns="jabber:client" id="agsXMPP_3" type="get"><oa xmlns="connect.logitech.com" errorcode="100" mime="harmony.engine?startActivity" errorstring="Continue"><![CDATA[done=7:total=10:deviceId=29923832]]></oa></iq>
<iq xmlns="jabber:client" id="agsXMPP_3" type="get"><oa xmlns="connect.logitech.com" errorcode="100" mime="harmony.engine?startActivity" errorstring="Continue"><![CDATA[done=8:total=10:deviceId=29923832]]></oa></iq>
<iq xmlns="jabber:client" id="agsXMPP_3" type="get"><oa xmlns="connect.logitech.com" errorcode="100" mime="harmony.engine?startActivity" errorstring="Continue"><![CDATA[done=9:total=10:deviceId=29923832]]></oa></iq>
<iq xmlns="jabber:client" id="agsXMPP_3" type="get"><oa xmlns="connect.logitech.com" errorcode="200" mime="harmony.engine?startActivity" errorstring="OK"><![CDATA[done=10:total=10:deviceId=29923833]]></oa></iq>

The first 200 makes the call work, but we could inform of progress changes. 1 of 10, 2 of 10 etc. Besides the activity changed event doesn't work when we send the change itself...

Slion commented 8 years ago

Besides the activity changed event doesn't work when we send the change itself...

I wonder if this is by design or if we are not doing the switch properly.

I have to admit I'm not using activities on my set up, well I have just the one activity. Therefore a lot of my work has been focused on using devices directly. I have not tested any of the activities related functionality.