Closed jfarmer08 closed 4 years ago
This already exists as a separate component. I use it for my door sensors and motion sensors from Wyze and it's been working flawlessly.
I agree but I do like keep my bridge plugged into the camera and being able to use the Wyze app. Looking at the API and Running https://api.wyzecam.com/app/v2/home_page/get_object_list i get a return of my 3 sensors. So would think most of the work is done. I am still learning how to add integrations for Home assistant. My return is below.
{ "ts": 1585675827352, "code": "1", "msg": "", "data": { "device_group_list": [], "device_list": [ { "mac": "77836023", "first_activation_ts": 1585666157000, "first_binding_ts": 1585666158000, "enr": "cAoCnvg/SKShswBK", "nickname": "Screen Door", "timezone_name": "", "product_model": "DWS3U", "product_model_logo_url": "https://s3-us-west-2.amazonaws.com/wyze-file/device-logo/small/wyze_icon_device_door.png", "product_type": "ContactSensor", "hardware_ver": "0.0.0.0", "firmware_ver": "0.0.0.16", "user_role": 1, "binding_user_nickname": "WyzeEMAIL", "conn_state": 1, "conn_state_ts": 1585666159222, "push_switch": 1, "device_params": { "open_close_state": 0, "open_close_state_ts": 1585666136032, "voltage": "76", "rssi": "96" }, "is_in_auto": 0, "event_master_switch": 1, "parent_device_mac": "2CAA8E1825A1", "parent_device_enr": "wp48OgIsusnT1BeC", "binding_ts": 1585666158000, "timezone_gmt_offset": 0.0 }, { "mac": "778458F7", "first_activation_ts": 1563484839000, "first_binding_ts": 1563484840000, "enr": "+Z6jAS/luTJGBdr6", "nickname": "Garage Door", "timezone_name": "", "product_model": "DWS3U", "product_model_logo_url": "https://s3-us-west-2.amazonaws.com/wyze-file/device-logo/small/wyze_icon_device_door.png", "product_type": "ContactSensor", "hardware_ver": "0.0.0.0", "firmware_ver": "0.0.0.16", "user_role": 1, "binding_user_nickname": "WyzeEMAIL", "conn_state": 1, "conn_state_ts": 1585666011325, "push_switch": 1, "device_params": { "open_close_state": 0, "open_close_state_ts": 1585674959235, "voltage": "90", "rssi": "86" }, "is_in_auto": 0, "event_master_switch": 1, "parent_device_mac": "2CAA8E1825A1", "parent_device_enr": "wp48OgIsusnT1BeC", "binding_ts": 1585666010000, "timezone_gmt_offset": 0.0 }, { "mac": "777F1FB1", "first_activation_ts": 1563487978000, "first_binding_ts": 1563487978000, "enr": "tTGKzUoWsyKC6+2A", "nickname": "Front Entry", "timezone_name": "", "product_model": "PIR3U", "product_model_logo_url": "https://s3-us-west-2.amazonaws.com/wyze-file/device-logo/small/wyze_icon_device_motion.png", "product_type": "MotionSensor", "hardware_ver": "0.0.0.0", "firmware_ver": "0.0.0.25", "user_role": 1, "binding_user_nickname": "WyzeEMAIL", "conn_state": 1, "conn_state_ts": 1585665969987, "push_switch": 1, "device_params": { "motion_state": 0, "motion_state_ts": 1585665958427, "voltage": "86", "rssi": "79" }, "is_in_auto": 0, "event_master_switch": 1, "parent_device_mac": "2CAA8E1825A1", "parent_device_enr": "wp48OgIsusnT1BeC", "binding_ts": 1585665927000, "timezone_gmt_offset": 0.0 }, { "mac": "2CAA8E1825A1", "first_activation_ts": 1558485588000, "first_binding_ts": 1558485590000, "enr": "wp48OgIsusnT1BeC", "nickname": "Front Door", "timezone_name": "America/Indiana/Indianapolis", "product_model": "WYZECP1_JEF", "product_model_logo_url": "https://s3-us-west-2.amazonaws.com/wyze-file/device-logo/small/wyze_icon_device_pan.png", "product_type": "Camera", "hardware_ver": "0.0.0.0", "firmware_ver": "4.10.5.111", "user_role": 1, "binding_user_nickname": "WyzeEMAIL", "conn_state": 1, "conn_state_ts": 1585665088000, "push_switch": 1, "device_params": { "p2p_id": "WRS4B9TFP4UJ9U93111A", "p2p_type": 3, "ssid": "WIFISSID", "ip": "192.168.1.55", "power_switch": 1, "temperature": "0", "humidity": "0", "temp_humi_room_type": 1, "comfort_standard_level": 2, "is_temperature_humidity": "0", "records_event_switch": 1, "motion_alarm_switch": 1, "audio_alarm_switch": 0, "smoke_alarm_switch": 0, "co_alarm_switch": 0, "electricity": "", "battery_charging_status": "", "is_link_toy_car": 0, "power_saving_mode_switch": 0 }, "is_in_auto": 1, "event_master_switch": 1, "parent_device_mac": "", "parent_device_enr": "", "binding_ts": 1562969726000, "timezone_gmt_offset": -4.00 } ], "device_sort_list": [ { "mac": "2CAA8E1825A1" } ] } }
I have made progress, but I sense this is new to me it might take awhile. Attach are my changes if anyone wants to look at it. wyzeapi.zip
Hey @jfarmer08 this integration was made to bridge the gap for devices made by wyze that have no method of connecting locally. Since wyze sensors have an alternative method for control it is out of scope for this project. I am not likely to add any code for this as I would not be able to maintain it. I do not have sensors connected to my wyze accounts.
I have made progress, but I sense this is new to me it might take awhile. Attach are my changes if anyone wants to look at it. wyzeapi.zip
Would you be interested in adding your code in GitHub? I'd like to take a look at it and possibly try it too, as I also like the idea of leaving the bridge plugged in the camera and connected with all the rest of the Wyze ecosystem. Normally I would suggest to create a new branch, but if Joshua doesn't want that to be included in here perhaps a fork would be more appropriate.
@lupalby If you would like to be a contributor on this project and maintain the sensor component that could work! I took a look at your fork and it is awesome work!
@JoshuaMulliken Thank you for having this library as a starting point! I have to admit that @jfarmer08 made things a lot easier. I just had to figure out which pids are used by the contact and motion sensors, and polished the code a little.
I tested my changes and they seem to work alright, the only problem is the update rate. The bulbs and switches only really need to fetch their status at the beginning, then HA will be what causes the status to change so there isn't really a need to continuously poll for changes. With the sensors it's totally different, because we don't do any action on them, we just need to read. The default polling interval is 5 or 30 minutes, I don't remember, in any case way too slow.
Do you know how to change the default polling interval? I tried to look everywhere but the only solution I found was to manually change it in the general code for binary_sensor, for the entire HA, that I don't think is a good approach. I also wonder is lowering that to e.g. 1-3 seconds may cause it to get banned for too many requests. The best would be to receive the notification without having to poll, but that's a much more complex problem. Any thought?
@lupalby The Wyze app does polling as well but all of the automatons in their app using the motion sensors take place on server side so I do not know how to get notifications from that. Probably the best way to use the sensors is https://github.com/kevinvincent/ha-wyzesense
I have fork the project with my changes for added in support for Sensors. I also made changes to Light and Switch so that they report the RSSI, Ip, SSID and Mac address for Attributes.
I have not made any changes to polling but the sensor normal update within 5 seconds. https://github.com/jfarmer08/ha-wyzeapi
The light and switch changes are really cool! can you create a pull request so we can get that code into this repo?
I have created a pull request. For the sensors we could add an option to the configuration and let the end user decided if they want to see them in home assistant or not.
@jfarmer08 Thank you! There is a beta release available that includes your code!
I have downloaded the release using HACS and so far no issues. I will also work on the polling and maybe add to the configuration for options.
@JoshuaMulliken I have add support to exclude devices from HA and support for Sensor Polling. @lupalby If you have sensors would you like to test this?
@JoshuaMulliken I have add support to exclude devices from HA and support for Sensor Polling. @lupalby If you have sensors would you like to test this?
Got a lot happening at work recently, but I'll give it a try soon. The 5 minutes polling makes the system almost useless at the moment, almost nothing stays open or in motion for such a long time. I have to say the information online to change that is quite scarce, I hope you find a solution!
@lupalby I am waiting on a pull request from @JoshuaMulliken before you will see the polling increase from 30 seconds to 5 seconds.
@lupalby Support for Polling the sensor has been add the latest beta release if you would like to try it.
Hey guys! I'm very impressed with your work here! I have a few bulbs and plugs, and everything is still working with the latest beta firmware updates released today! I can see all my contact and motion sensors showing up as entities, but I had a question about those. I'm still new to HA and am learning how to run automation now.
EDIT:
I just got an automation working, but as I see above, it's only polled every 5 seconds for changes. I had converted one of their contact sensors into a push button, but the button needs to be held down for up to 5 seconds for it to trigger properly. So, this is not really solving my latency problem, but understanding a bit better how these things work (being read only), I'm not sure it's possible to make this thing low latency. I saw something about polling too often, I assume you are pinging Wyze's cloud? Is there no way to strictly poll locally if you have the mac address of the sensor?
Anyways, appreciate all your hard work!
@Caustik314 If you need faster polling then i would recommend using https://github.com/kevinvincent/ha-wyzesense
This is now in the 0.5.0-beta.1 release!!!!!
@Caustik314 If you need faster polling then i would recommend using https://github.com/kevinvincent/ha-wyzesense
Finally got around to reading about that today, turns out, they do not have it working with HA Supervisor yet. So I guess I'll be re-installing yours and dealing with the 5 second polling for now! :) Thanks again guys!
EDIT: Turns out it does work! I just can't get both of my bridges going. I'm actually using both yours and Kevin's integrations, just using sensors: false in the config on yours and they are working great together!
@Caustik314 That's great man!!
Hey quick question for ya, it really seems like the bulbs and switches are being controlled locally, do I need the api connection after the first run? Or is there some way to assign names and ip addresses in the configuration.yaml to do so? I'm trying to figure out if it is even possible to completely remove my devices from the internet and keep them 100% local with this integration. This is strictly for the bulbs and switches. Also, if you ever plan on adding scale or watch support to this api integration, I could help with testing as I own those products as well, and are probably the only things I would keep online if anything. Thanks for your time and hard work! :)
@Caustik314 The whole project needs a connection back to Wyze API. This is the only way it will work. We could bring in the scale and Band, but I do not have the time.
Can support for Sensors be added?