Wyze sense sensor integrations

@MediaCowboy About that… I updated the README earlier today as I realized the signal strength and the battery level had some intricacies that needed explaining:

Notes on selected Sensor Attributes:

  • signal_strength : This is the absolute value of the RSSI, not a percentage. As such, lower is stronger. By definition, RSSI doesn’t have upper and lower bounds so it can’t be translated into a percentage unless specified by Wyze what the bounds are.
  • battery_level : The sensor does a basic calculation with the battery voltage. Because of this, battery percentage may be higher than 100% when you first get a sensor.

If anyone has suggestions on if its worth guessing the bounds and converting to a percentage let me know. Maybe it could also be changed to just plain rssi to avoid confusion.

1 Like

@kevinvincent, I would say RSSI Signal. Thanks for that info its been a long day and haven’t read all the docs yet.

1 Like

@MediaCowboy I agree. signal_strength is now rssi. Code and README have been updated accordingly and pushed. It will update the attribute the next time the sensor triggers. I got some questions about that too through github so this is definitely less confusing. Thanks for the input!

1 Like

Glad I could be of help. The wyze stuff was brought up on the podcast so you may have more people coming. I pointed it out on discord podcast channel.

I just checked out the discord. Thank you! Next week I’m gonna see what it’ll take to get this into HA by default. It seems to meet all the requirements. I appreciate all the effort you’ve put into the early debugging, feature suggestions, and answering questions around here.

1 Like

Is anyone that is running @kevinvincent’s custom component doing so in Docker? How are you passing the USB port into the container? Just running it in privileged mode?

Running mine in docker on Unraid. Unraid has a GUI where you can just point the container to the USB device path to pass it through so that’s how I’m doing it. Works perfectly.

1 Like

You can do privileged mode or does just docker run --device=/dev/hidraw<number> .... work?

My HA is just in privileged mode though since that seemed like the default.

1 Like

I’m currently running gosense but if you are going to try to get yours incorporated into core I may as well switch now and do away with the mqtt requirement. I’ll go ahead with privileged mode.

1 Like

@atomicpapa, I am currently running docker. Host is ubuntu. What is your host OS? I can share my home assistant docker section.

running Ubuntu 18.04 as my host system. Thanks!

@atomicpapa, hope this helps.

  home-assistant:
    image: "homeassistant/home-assistant"
    container_name: "home-assistant"
    restart: unless-stopped
    volumes:
      - ${USERDIR}/docker/home-assistant:/config
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - /mnt/media/Podcast/Home Assistant:/podcast
    network_mode: host
    devices:
      - /dev/ttyUSB0:/dev/ttyUSB0 #Linear HUSBZB-1
      - /dev/ttyUSB1:/dev/ttyUSB1 #Linear HUSBZB-1
      - /dev/hidraw1:/dev/hidraw4 #Wyze Sense Hub
    environment:
      - PUID=${PUID}
      - PGID=${PGID}
      - TZ=${TZ}
    depends_on:
      - mqtt

I used the following command to detect which device was the wuze sense:

dmesg | grep hidraw

Super easy setup, thanks to everyone that worked on this.
I added a template sensor for the battery level that I wanted to share.
First time I tried to make one so I’m not 100% sure if the code is correct, but it works fine on my setup.

- platform: template
  sensors:
    laundry_room_battery:
      friendly_name: 'Laundry Room'
      value_template: "{{ state_attr('binary_sensor.wyzesense_7xxxxxxx', 'battery_level') }}"
      unit_of_measurement: '%'
      device_class: battery
4 Likes

@kevinvincent, I created a pull request for an additional step to help detect which hidraw the wyze bridge is using.

Just a small tip, you can get rid of all the icon_template: stuff and replace it with device_class: battery instead.

It does the exact same stuff as the icon_template but saves like ~20 lines of code. Just makes things a bit cleaner, especially if you plan to add more template sensors.

1 Like

Cool thanks. At one point when I compared this sensor to my other ones I thought “it would be nice to be able to set the sensor type” but I had no idea how to do it. Time to simplify the code. I edited the original post.

1 Like

@kevinvincent how do i change the door/window sensor from a door to a window?

Thanks

Wonderful work! Thank you!

I wish I knew golang so I could help. One of the few I’ve never bothered to learn. Maybe now is the time.

Regardless, it’s working perfectly!

@MediaCowboy thank you! I’ll take a look at the changes when I can get back to my computer on Monday and pull them in

The entity will always represent the true type of sensor, however you can customize how it appears to home assistant using this method https://www.home-assistant.io/docs/configuration/customizing-devices/

Just change the device class as you’d like.