ZacheryThomas / smartrent-py

Api for SmartRent locks 🔐, thermostats 🌡, moisture sensors 💧 and switches💡

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Request: Add 'battery_powered' and 'battery_level' detection

gwnichol opened this issue · comments

Hello, I just recently moved into an apartment with Smart Rent and am setting up my first instance of Home Assistant. I noticed that the API responses include the battery level and whether the device is battery powered.

Would you be interested in exposing this data for eventual use in your Home Assistant integration?

I'd also be interested in helping develop this feature.

Partial prints of devices_resp.json():

With battery power:

{
  'battery_level': 97,
  'battery_powered': True,
  'icon': None,
  'name': 'Front Door - Lock',
  'online': True
}

Without battery power:

{
    'battery_level': None,
    'battery_powered': False,
    'icon': None,
    'name': 'Bar',
    'online': True, 
    'type': 'switch_binary'
}

There aren't yet any properties stored in the Device base but would a battery_level : Optional[int] make sense there?

commented

Hello! Thanks for reaching out!

I'll have to think about how best to add this. When I first made the project I wanted all of the device attributes to update automatically when new data comes in w/ our websocket. Unfortunately it doesn't seem like we get battery info through our websocket connection so that complicates things.

commented

I added a preliminary example of this feature to the develop branch of this repo! Feel free to try it out and see if it meets your needs. I will probs add it to main & make a release in a week or so if everything ends up working out right.

commented

Added this feature in the latest release!

https://github.com/ZacheryThomas/smartrent.py/releases/tag/v0.2.5

Im looking at adding support for battery sensors in the Home Assistant component soon.