sucks
sucks copied to clipboard
VacBot.*_status never gets set
I've been able to use the sucks library to start and stop my Ecovacs N79s. However, I can't get it to accurately to report status on anything.
I'm using the Cmdswitch2-Ecovacs script: https://github.com/EtienneMD/Cmdswitch2-Ecovacs to integrate with Homebridge.
Running the script through the debugger, I can see the request to get charge status:
DEBUG:sucks:Sending command <iq id="XXX" to="XXX" from="XXX" type="set"><query xmlns="com:ctl"><ctl td="GetChargeState" /></query></iq> DEBUG:sleekxmpp.xmlstream.xmlstream:SEND: <iq id="XXX" to="XXX" from="XXX" type="set"><query xmlns="com:ctl"><ctl td="GetChargeState" /></query></iq> DEBUG:sleekxmpp.xmlstream.xmlstream:RECV: <iq to="XXX" type="result" id="XXX" from="XXX" /> DEBUG:sleekxmpp.xmlstream.xmlstream:RECV: <iq to="XXX" type="set" id="25665" from="XXX"><query xmlns="com:ctl"><ctl id="" ret="ok" errno=""><charge type="SlotCharging" /></ctl></query></iq>
I see the response is sending the correct answer, but inside EcoVacsXMPP._handl_ctl(), the message.getpayload() call only returns the outer <charge>
element that actually contains the information. I'm guessing this is why the status information isn't being set.
I don't know enough about SleekXMPP to get to the next step. I'm hoping you can shed some light as to where to look to solve the problem.
The outer element should contain the inner elements. When debugging did you keep stepping forward to see what happens in _handle_charge_state
? That's where the VacBot logic happens to handle that message.
It would be best if you set your sucks log level to DEBUG and post the full console output when trying to run your script.
_handle_charge_state
never gets called (put a breakpoint there first...)
Here's what I'm running:
`vacbot = ConnectVac() vacbot.run(GetChargeState())
_LOGGER.debug("Charge Status:[" + str(vacbot.charge_status) + "]")
sleep(5)
_LOGGER.debug("Charge Status:[" + str(vacbot.charge_status) + "]") `
`DEBUG:root:Switching to shorter UID XXX
DEBUG:root:EcoVacsAPI connection complete
DEBUG:sucks:calling user api GetDeviceList with {'userid': 'XXX', 'auth': {'with': 'users', 'userid': 'XXX', 'realm': 'ecouser.net', 'token': 'XXX', 'resource': 'XXX'}}
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): users-na.ecouser.net:8000
DEBUG:urllib3.connectionpool:https://users-na.ecouser.net:8000 "POST /user.do HTTP/1.1" 200 171
DEBUG:sucks:got {'todo': 'result', 'result': 'ok', 'devices': [{'did': 'XXX', 'name': 'XXX', 'class': '155', 'resource': 'atom', 'nick': None, 'company': 'eco-legacy'}]}
DEBUG:sleekxmpp.plugins.base:Loaded Plugin: RFC 6120: Stream Feature: STARTTLS
DEBUG:sleekxmpp.plugins.base:Loaded Plugin: RFC 6120: Stream Feature: Resource Binding
DEBUG:sleekxmpp.plugins.base:Loaded Plugin: RFC 3920: Stream Feature: Start Session
DEBUG:sleekxmpp.plugins.base:Loaded Plugin: RFC 6121: Stream Feature: Roster Versioning
DEBUG:sleekxmpp.plugins.base:Loaded Plugin: RFC 6121: Stream Feature: Subscription Pre-Approval
DEBUG:sleekxmpp.plugins.base:Loaded Plugin: RFC 6120: Stream Feature: SASL
WARNING:sleekxmpp.basexmpp:fulljid property deprecated. Use boundjid.resource
DEBUG:sleekxmpp.xmlstream.xmlstream:Waiting 1.9544798217727324 seconds before connecting.
DEBUG:sleekxmpp.xmlstream.resolver:DNS: Querying msg-na.ecouser.net for AAAA records.
DEBUG:sleekxmpp.xmlstream.resolver:DNS: Querying msg-na.ecouser.net for A records.
DEBUG:sleekxmpp.xmlstream.xmlstream:Connecting to [::ffff:47.88.66.164]:5223
DEBUG:sleekxmpp.xmlstream.xmlstream:Event triggered: connected
DEBUG:sleekxmpp.thirdparty.statemachine: ==== TRANSITION disconnected -> connected
DEBUG:sleekxmpp.xmlstream.xmlstream:Starting HANDLER THREAD
DEBUG:sleekxmpp.xmlstream.xmlstream:Loading event runner
DEBUG:sleekxmpp.xmlstream.xmlstream:SEND (IMMED): <stream:stream to='ecouser.net' xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client' xml:lang='en' version='1.0'>
DEBUG:sleekxmpp.xmlstream.xmlstream:RECV: <stream:stream version="1.0" id="XXX" from="ecouser.net">
DEBUG:sleekxmpp.xmlstream.xmlstream:RECV: <stream:features xmlns="http://etherx.jabber.org/streams">
DEBUG:sleekxmpp.xmlstream.xmlstream:Event triggered: ssl_cert
WARNING:sleekxmpp.xmlstream.cert:Could not find pyasn1 and pyasn1_modules. SSL certificate COULD NOT BE VERIFIED.
DEBUG:sleekxmpp.xmlstream.xmlstream:SEND (IMMED): <stream:stream to='ecouser.net' xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client' xml:lang='en' version='1.0'>
DEBUG:sleekxmpp.xmlstream.xmlstream:RECV: <stream:stream version="1.0" id="XXX" from="ecouser.net">
DEBUG:sleekxmpp.xmlstream.xmlstream:RECV: <stream:features xmlns="http://etherx.jabber.org/streams">
Same here - I added a debug line in my module and printed the responses below - seems they don't have the td attribute, just an empty id="" so this line 462 is causing it to just return.
DEBUG:sucks:Message payload: <ns0:ctl xmlns:ns0="com:ctl" errno="" id="" ret="ok"><ns0:clean a="" speed="standard" st="h" t="" type="stop" /></ns0:ctl>
DEBUG:sucks:Message payload: <ns0:ctl xmlns:ns0="com:ctl" errno="" id="" ret="ok"><ns0:charge type="SlotCharging" /></ns0:ctl>
DEBUG:sucks:Message payload: <ns0:ctl xmlns:ns0="com:ctl" errno="" id="" ret="ok"><ns0:battery power="039" /></ns0:ctl>
DEBUG:sucks:Message payload: <ns0:ctl xmlns:ns0="com:ctl" errno="" id="" ret="ok" total="365" type="Brush" val="084" />
DEBUG:sucks:Message payload: <ns0:ctl xmlns:ns0="com:ctl" errno="" id="" ret="ok" total="365" type="SideBrush" val="061" />
DEBUG:sucks:Message payload: <ns0:ctl xmlns:ns0="com:ctl" errno="" id="" ret="ok" total="365" type="DustCaseHeap" val="064" />