Page 1 of 1

Display Battery Level for custom devices

PostPosted: Tue May 12, 2020 9:15 pm
by jheddings
Posting this in case anyone can help for a future release...

Is there a way to use the built in
Code: Select all
batteryLevel
device state for custom devices? When I try to use that in this plugin, the device state is hidden and no meter shows on the UI. I'm currently using a generic
Code: Select all
level
state, but it would be nice to build on the known states where possible.

Thanks!
-jh

Re: Display Battery Level for custom devices

PostPosted: Wed May 13, 2020 5:21 am
by FlyingDiver
For it to show in the UI, in your device definition you need:
Code: Select all
            <Field id="SupportsBatteryLevel" type="checkbox" defaultValue="false">
                <Label>Device reports battery status:</Label>
            </Field>           


If the custom device always has a battery level, then just set that to True and hide it in the Devices.xml.

Code: Select all
         <Field id="SupportsBatteryLevel" type="checkbox" defaultValue="true" hidden="true" />

Re: Display Battery Level for custom devices

PostPosted: Wed May 13, 2020 8:26 am
by jheddings
Works like a charm, thanks! I've kept the legacy state for compatibility with existing devices. Any new Battery devices will display the battery indicator. I'll make note of this when I do a new release.