-
-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show only battery-holding devices in device-dropdown when creating a new Battery-Note #93
Comments
I did look at this but couldn't seem to find a way to filter devices to those with a certain entity
|
Have a gander here... The example shows how to look for devices that provide a battery sensor. |
Thanks, I did see that but translating that YAML example to Python is where I'm getting stuck at the moment. |
I'll take a look. |
I'm not in a position to test but I think this should work (or at least get you close) You will need to add the following to the block of imports... from homeassistant.const import Platform
from homeassistant.components.sensor import SensorDeviceClass This would be your device selector vol.Required(CONF_DEVICE_ID): selector.DeviceSelector(
config=selector.DeviceSelectorConfig(
entity=[
selector.EntityFilterSelectorConfig(
domain=Platform.SENSOR,
device_class=SensorDeviceClass.BATTERY,
)
]
)
), UPDATE: Realised I'd used the wrong selector definitions in places. |
Thanks, just tested that and it seems to work. A lot more testing and a config option to override this before I release. For dev I'm always adding a PP3 battery to the Sun to save adding physical devices to my dev instance :) |
There's a possibility that you may need to add an entity filter to check for the binary_sensor domain as well. I know the blink integration uses that domain for battery sensors as it can only report on good/bad state. The |
@uvjim Pleased to say the selector is "one of", even though I've not got binary_sensor batteries I'm not losing my sensor batteries by adding them. My testing will continue but looks like this is going to work. |
@andrew-codechimp that's good then. Glad I could be of some help. Keep up the learning and good work. |
A Beta version has now been released with the both Battery Last Replaced sensor, button & service plus the device picker when manually adding now only shows devices with batteries (can be changed, see FAQ). If you wish to try this version please go into HACS, select Battery Notes and in the top right menu choose Redownload, switch on Show Beta Versions and select the latest version (starts with 1.3) |
Checklist
Is your feature request related to a problem? Please describe.
The list of devices the dropdown for devices when creating a new battery-note contains all available devices. This is/can be a very long list. Most many devices do not have a battery and are unnecessary in the list.
Describe the solution you'd like
Fill the devices list with a filter that only includes devices which has a battery
Describe alternatives you've considered
NA
Additional context
NA
The text was updated successfully, but these errors were encountered: