Unwanted battery level status on sub-devices

Posted on
Thu Mar 01, 2018 11:47 am
FlyingDiver offline
User avatar
Posts: 7215
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Unwanted battery level status on sub-devices

I'm pretty sure I read on these forums that grouped devices should only show battery level on the "root" device. So that's what I tried to implement for one of the device types supported by the RFPlayer dongle plugin.

Here's the device definition:
Code: Select all
   <Device type="sensor" id="oregonDevice">
        <Name>Oregon Scientific Device</Name>
        <ConfigUI>
            <SupportURL>http://forums.indigodomo.com/viewforum.php?f=214</SupportURL>

         <Field id="SupportsOnState" type="checkbox" defaultValue="false" hidden="true" />
         <Field id="SupportsSensorValue" type="checkbox" defaultValue="true" hidden="true" />
         <Field id="SupportsStatusRequest" type="checkbox" defaultValue="false" hidden="true" />
         <Field id="AllowOnStateChange" type="checkbox" defaultValue="false" hidden="true" />

            <Field id="address" type="menu">
                <Label>Device:</Label>
                <List class="self" filter="5" method="availableDeviceList"/>
            </Field>           
        </ConfigUI>
    </Device>      


The base definition does not have SupportBatteryLevel true because I reuse this definition for all devices of this type.

I have this code run when the device is started for the first time:

Code: Select all
        # update the master device, depending on the actual device type

        if subType not in ['0x1A89', '0x2A19', '0xDA78']:
       
            device.updateStateImageOnServer(indigo.kStateImageSel.TemperatureSensor)
            device.name = devAddress + " Thermometer"
            device.subModel = "Thermometer"
            device.replaceOnServer()

            newProps = device.pluginProps
            newProps["configDone"] = True
            newProps["valueType"] = "temperature"
            newProps["SupportsBatteryLevel"] = True
            device.replacePluginPropsOnServer(newProps)


SupportsBatteryLevel is set True here, for the "master" device. Then, depending on the specific model, I run:

Code: Select all
        # create any subdevices
 
        if subType in ['0x1A2D', '0xCA2C', '0x0ACC', '0x1A3D', '0xFA28']:
   
            self.logger.info(u"Adding Hygrometer subDevice to '%s' (%s) @ %s" % (device.name, device.id, devAddress))

            newdev = indigo.device.create(indigo.kProtocol.Plugin,
                                            address=devAddress,
                                            name=devAddress + " Hygrometer",
                                            deviceTypeId="oregonDevice",
                                            groupWithDevice=device.id,
                                            props={ 'valueType': 'hygrometry',
                                                    'configDone': True,
                                                    'AllowOnStateChange': False,
                                                    'SupportsOnState': False,
                                                    'SupportsSensorValue': True,
                                                    'SupportsStatusRequest': False
                                                },
                                            folder=device.folderId)
                                                   
            newdev.updateStateImageOnServer(indigo.kStateImageSel.HumiditySensor)
            newdev.model = device.model
            newdev.subModel = "Hygrometer"       # Manually need to set the model and subModel names (for UI only)
            newdev.replaceOnServer()   


So, no SupportsBatteryLevel for the sub device. But what I get battery level indicators for both devices. See screen grabs. Yes, I'm updating both levels at the moment, but when I wasn't it was showing the correct value for the main device and 0% for the secondary device.

I've deleted and recreated the devices multiple times. No changes.
Attachments
Screen Shot 2018-03-01 at 12.44.48 PM 3-1.png
Screen Shot 2018-03-01 at 12.44.48 PM 3-1.png (98.16 KiB) Viewed 972 times
Screen Shot 2018-03-01 at 12.44.36 PM 3-1.png
Screen Shot 2018-03-01 at 12.44.36 PM 3-1.png (98.19 KiB) Viewed 972 times

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Thu Mar 01, 2018 3:54 pm
jay (support) offline
Site Admin
User avatar
Posts: 18219
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Unwanted battery level status on sub-devices

Print the device (that shouldn't be showing battery level) in the scripting shell so we can see everything defined for it.

[EDIT]

Here are two grouped Z-Wave device definitions with everything stripped out but the relevant parts:

Code: Select all
##### Dependent Device #####
batteryLevel : None
ownerProps : com.perceptiveautomation.indigoplugin.zwave : (dict)
     SensorUnits : 2 (integer)
     SupportsOnState : false (bool)
     SupportsSensorValue : true (bool)
     SupportsStatusRequest : false (bool)
states : States : (dict)
     sensorValue : 0.000000 (real)
     sensorValue.ui : 0 lux (string)

##### Primary/main Device #####
batteryLevel : 100
ownerProps : com.perceptiveautomation.indigoplugin.zwave : (dict)
     SupportsBatteryLevel : true (bool)
states : States : (dict)
     batteryLevel : 100 (integer)
     batteryLevel.ui : 100% (string)


The top one is the dependent device which doesn't show battery. The batteryLevel property is None, SupportsBatteryLevel isn't in the ownerProps, and batteryLevel and batteryLevel.ui states don't exist.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Thu Mar 01, 2018 4:00 pm
FlyingDiver offline
User avatar
Posts: 7215
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Unwanted battery level status on sub-devices

Code: Select all
Started Plugin RFPlayer v7.1.0
>>> print indigo.devices[1598481]
address : OREGON-46081
allowOnStateChange : False
allowSensorValueChange : False
batteryLevel : 80
buttonGroupCount : 0
configured : True
description :
deviceTypeId : oregonDevice
displayStateId : sensorValue
displayStateImageSel : DehumidifierOff
displayStateValRaw : 66.0
displayStateValUi : 66%
enabled : True
energyAccumBaseTime : None
energyAccumTimeDelta : None
energyAccumTotal : None
energyCurLevel : None
errorState :
folderId : 1912224990
globalProps : MetaProps : (dict)
     com.flyingdiver.indigoplugin.rfplayer : (dict)
          AllowOnStateChange : false (bool)
          SupportsBatteryLevel : true (bool)
          SupportsOnState : false (bool)
          SupportsSensorValue : true (bool)
          SupportsStatusRequest : false (bool)
          address : OREGON-46081 (string)
          configDone : true (bool)
          devVersCount : 2 (integer)
          faultCode : None (empty)
          valueType : hygrometry (string)
id : 1598481
lastChanged : 2018-03-01 16:59:24
lastSuccessfulComm : 2018-03-01 16:59:24
model : Oregon Scientific Device
name : OREGON-46081 Hygrometer
onState : None
ownerProps : com.flyingdiver.indigoplugin.rfplayer : (dict)
     AllowOnStateChange : false (bool)
     SupportsBatteryLevel : true (bool)
     SupportsOnState : false (bool)
     SupportsSensorValue : true (bool)
     SupportsStatusRequest : false (bool)
     address : OREGON-46081 (string)
     configDone : true (bool)
     devVersCount : 2 (integer)
     faultCode : None (empty)
     valueType : hygrometry (string)
pluginId : com.flyingdiver.indigoplugin.rfplayer
pluginProps : com.flyingdiver.indigoplugin.rfplayer : (dict)
     AllowOnStateChange : false (bool)
     SupportsBatteryLevel : true (bool)
     SupportsOnState : false (bool)
     SupportsSensorValue : true (bool)
     SupportsStatusRequest : false (bool)
     address : OREGON-46081 (string)
     configDone : true (bool)
     devVersCount : 2 (integer)
     faultCode : None (empty)
     valueType : hygrometry (string)
protocol : Plugin
remoteDisplay : True
sensorValue : 66.0
states : States : (dict)
     batteryLevel : 80 (real)
     batteryLevel.ui : 80% (string)
     faultCode :  (string)
     sensorValue : 66.000000 (real)
     sensorValue.ui : 66% (string)
subModel : Hygrometer
supportsAllLightsOnOff : False
supportsAllOff : False
supportsOnState : False
supportsSensorValue : True
supportsStatusRequest : False
version : None
>>>

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Thu Mar 01, 2018 4:02 pm
jay (support) offline
Site Admin
User avatar
Posts: 18219
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Unwanted battery level status on sub-devices

So, all the battery information is in that device definition. Somehow it's getting added, but we don't seen enough of the code to know where it's getting added. But it's definitely getting added somewhere or those states and props wouldn't be there.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Thu Mar 01, 2018 4:19 pm
FlyingDiver offline
User avatar
Posts: 7215
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Unwanted battery level status on sub-devices

So it's got to be that "SupportsBatteryLevel" is getting added to the pluginProps, right? And if it's not in the Devices.xml, then it has to be in device.replacePluginPropsOnServer(newProps) call? Is there any other way it could happen?

.............

Grrr. Never Mind. Found it. Doing code to fix up existing devices for new properties is really complicated....

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests