homebridge-plugins / homebridge-ewelink

Homebridge plugin to integrate eWeLink devices into HomeKit.
MIT License
389 stars 127 forks source link

Interest in gathering information from devices and subdevices via API #343

Closed shanelilley closed 2 years ago

shanelilley commented 2 years ago

Hey! API is great, love it... Using it to push status etc out to MQTT. But I've noticed I cannot obtain info such as a door sensor 'state' . Return from direct deviceID query is "'accessory.control.currentState is not a function.'"

I notice even if I dig in to the return object/json there is no "state" of any kind (open/closed/tripped).

Do I need to perhaps query ewelink directly?

Cheers! Shane

bwp91 commented 2 years ago

hiya, which device types in particular are you looking to query with the api? im kinda implementing things on a request basis!

shanelilley commented 2 years ago

Hey! So require -

bwp91 commented 2 years ago

Please update to the beta version, I have implemented get state for these device types, controlling will hopefully come tomorrow!

shanelilley commented 2 years ago

Awesome! Just tested, switches and lights look good! Simulations for irrigation valves and the Echeon roller door and the contact sensors are the other ones I really need if that is at all possible?

bwp91 commented 2 years ago

Should be working for the devices you have mentioned too, did you update to the beta?

shanelilley commented 2 years ago

Irrigation valve (single relay as a valve) -

Back garden main solenoid 100134c534SWX {'name': 'Back garden main solenoid', 'hbdeviceid': '100134c534SWX', 'status': {'wan': True, 'lan': True, 'ip': '192.168.201.140'}}

Query directly on the device itself -

100134c534SWX {'success': False, 'error': 'accessory.control.currentState is not a function.'}

Yep beta running with all prerequistes... I can actually see now lights, switches, temperature, contact sensors.

shanelilley commented 2 years ago

Ah, I see you list "garage" as a service type, so the Echeon simulation works perfectly. What I cannot see is the irrigation valve type.

shanelilley commented 2 years ago

So last thing I notice is that we get a weird return on the json for "power" devices - we get 'power' and 'switch' as services and the actual switch state which is good. However the 'power' state gives a very long number, not sure if its encoded?

Hoping to be able to get the current kw power reading from the device.

Device Name: POWR3Device37b934 {'success': True, 'response': {'status': {'wan': True, 'lan': True, 'ip': '192.168.201.162'}, 'services': ['switch', 'power'], 'switch': {'state': 'on'}, 'power': {'state': '010805040304030405030100030100030205030304030009030104030303030504030404030606030800040101040301040601030506030602030305030306030409030806030600030408030302030208030307030306030500030607030206030203030106030101030008030400030605030103030007030000020902020803030101040408030305030101020907030001020906030102030308030107030005030005030107040506040104030701030200020908020408020307020808030105020707020803030000030306030100020906020901030404020808020801030501030405020601020605020802020803020903030300030004020407010804020408010505010701020407020002020707010903030506010902010700020004030200020604030308'}}}

Kind regards, Shane

bwp91 commented 2 years ago

Please check the latest beta, you should also see current power, current and voltage via the API. These long numbers are usage history for the last 100 days, I will find a reference to how to decode it, it's in a closed issue on here somewhere!

bwp91 commented 2 years ago

https://github.com/bwp91/homebridge-ewelink/issues/292#issuecomment-915844645

shanelilley commented 2 years ago

oh brilliant! Makes sense. Installed and testing....

bwp91 commented 2 years ago

which irrigation simulation do you use? I thought you used the 'switch + valve' one?

shanelilley commented 2 years ago

So I take a Sonoff basic/mini/RF/SV as per the GUI for single and double channel devices as show as a single or double irrigation valve. Is that what you mean? Cheers, Shane

shanelilley commented 2 years ago

This is the response I get back when I query a switch/solenoid directly -

Device Name: Back garden main solenoid {'success': False, 'error': 'accessory.control.currentState is not a function.'}

Hope this helps! Kind regards, Shane

bwp91 commented 2 years ago

is this for your valve? i haven’t implemented for valve yet, i thought you used the “valve + switch” simulation 😆

bwp91 commented 2 years ago

i will get to it

bwp91 commented 2 years ago

Can you try 8.11.3-beta.4?

shanelilley commented 2 years ago

Can do! installing now :-)

shanelilley commented 2 years ago

Ok - so I can see "valve" and looking good with state. Very cool!

stale[bot] commented 2 years ago

This issue has been automatically marked as inactive because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

bwp91 commented 2 years ago

@shanelilley ive gotten a bit lost is there anything else you need from the api?

shanelilley commented 2 years ago

@bwp91 - yep been testing on .12 and all looks really awesome. Definitely time to close this one off and again awesome work and many thanks! The API method is just so much better and rock solid. Shane.