Native States

Posted on
Sat Sep 05, 2020 3:12 pm
vtmikel offline
Posts: 542
Joined: Aug 31, 2012
Location: Boston, MA

Native States

I'm having trouble figuring this out. After creating a dimmer RGBW device defined by my plugin, I'm occasionally getting these messages while editing the device in my indigo client.

Code: Select all
Error (client)                  illegal state key blueLevel defined by plugin -- native state keys cannot be overriden (ignoring)
   Error (client)                  illegal state key brightnessLevel defined by plugin -- native state keys cannot be overriden (ignoring)
   Error (client)                  illegal state key greenLevel defined by plugin -- native state keys cannot be overriden (ignoring)
   Error (client)                  illegal state key onOffState defined by plugin -- native state keys cannot be overriden (ignoring)
   Error (client)                  illegal state key redLevel defined by plugin -- native state keys cannot be overriden (ignoring)
   Error (client)                  illegal state key whiteLevel defined by plugin -- native state keys cannot be overriden (ignoring)
   Error (client)                  illegal state key whiteTemperature defined by plugin -- native state keys cannot be overriden (ignoring)


I do not believe my plugin is attempting to do anything it shouldnt. Despite the messages saying the instructions are being ignored, the device behaves oddly afterwards.

For example, I'll do something like:

Code: Select all
dev.updateStateOnServer("brightnessLevel", 0)


The textbox in the indigo client will change to the correct brightness level, but the "Device Details" will show the old value, and so will the "State" column in the device list.

Posted on
Sat Sep 05, 2020 3:42 pm
FlyingDiver offline
User avatar
Posts: 5351
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Native States

What's your Devices.xml look like? Do you have those states defined there? Because if you're using type="dimmer", then those are already defined.

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

Posted on
Sat Sep 05, 2020 3:46 pm
matt (support) offline
Site Admin
User avatar
Posts: 20569
Joined: Jan 27, 2003
Location: Texas

Re: Native States

[Joe beat me to replying 8) ]

In your Devices.xml did you add those states (blueLevel, brightnessLevel, etc.)? Those shouldn't be added to your XML as the Indigo Server automatically adds those if the device type is dimmer and you have the SupportsColor, SupportsRGB, SupportsWhite, etc. set.

Image

Posted on
Sat Sep 05, 2020 3:47 pm
vtmikel offline
Posts: 542
Joined: Aug 31, 2012
Location: Boston, MA

Re: Native States

I do have some (not brightnessLevel or onOffState). I followed the plugin SDK because I wasn't familiar with these RGB devices. Here is a portion of my devices.xml. A straight copy and paste from the SDK examples.

Code: Select all
            <Field type="checkbox" id="SupportsRGB" defaultValue="true">
                <Label>Supports RGB:</Label>
                <Description>Shows RGB control and level fields in UI</Description>
            </Field>
            <Field type="separator" id="simpleSeparator2" />
            <Field type="checkbox" id="SupportsWhite" defaultValue="true">
                <Label>Supports White:</Label>
                <Description>Shows White level fields in UI</Description>
            </Field>
            <Field type="checkbox" id="SupportsTwoWhiteLevels" defaultValue="false" enabledBindingId="SupportsWhite">
                <Label>Supports White 2:</Label>
                <Description>Shows Two White level fields in UI</Description>
            </Field>
            <Field type="label" id="whiteInfoField" fontColor="darkgray" fontSize="small">
                <Label>Two white level fields are used by some hardware to mix cool and warm white levels. Other hardware provides this capability by using a white temperature value. The two techniques are mutually exlcusive, so choosing to enable two white levels will override (and not show) the white temperature UI.</Label>
            </Field>
            <Field type="checkbox" id="SupportsWhiteTemperature" defaultValue="false" enabledBindingId="SupportsWhite" visibleBindingId="SupportsTwoWhiteLevels" visibleBindingValue="false" alwaysUseInDialogHeightCalc="true">
                <Label>Supports White Temp:</Label>
                <Description>Shows White Temperature field in UI</Description>
            </Field>
            <Field type="textfield" id="WhiteTemperatureMin" defaultValue="1200" visibleBindingId="SupportsWhiteTemperature" visibleBindingValue="true" alwaysUseInDialogHeightCalc="true">
                <Label>Minimum White Temperature:</Label>
                <Description>Minimum White Temperature used on UI controls</Description>
            </Field>
            <Field type="textfield" id="WhiteTemperatureMax" defaultValue="6500" visibleBindingId="SupportsWhiteTemperature" visibleBindingValue="true" alwaysUseInDialogHeightCalc="true">
                <Label>Maximum White Temperature:</Label>
                <Description>Maximum White Temperature used on UI controls</Description>
            </Field>

Posted on
Sat Sep 05, 2020 4:01 pm
vtmikel offline
Posts: 542
Joined: Aug 31, 2012
Location: Boston, MA

Re: Native States

I'm adding SupportsColor to my devices.xml.

I've wiped the slate clean. Re-created my plugin device. I almost immediately get this message below. The other RGB states were not mentioned this time.

Code: Select all
Error (client)                  illegal state key brightnessLevel defined by plugin -- native state keys cannot be overriden (ignoring)
   Error (client)                  illegal state key onOffState defined by plugin -- native state keys cannot be overriden (ignoring)


I've checked 10x, I dont have these defined in my devices.xml.

Posted on
Sat Sep 05, 2020 4:47 pm
matt (support) offline
Site Admin
User avatar
Posts: 20569
Joined: Jan 27, 2003
Location: Texas

Re: Native States

Copy/paste the contents of your Devices.xml so we can try to figure out what is causing it.

And when specifically do you get the error? When the plugin starts, when you open the device dialog to create a new device, when you close the device dialog, etc.

Image

Posted on
Mon Sep 07, 2020 6:57 am
vtmikel offline
Posts: 542
Joined: Aug 31, 2012
Location: Boston, MA

Re: Native States

Walking away from the problem for the evening and returning, it seems to be fixed. I believe it was malformed XML but I cannot be sure. I have not seen the problem return in the past few days. Thanks for pointing me to where the issue was.

Posted on
Mon Sep 07, 2020 7:19 am
vtmikel offline
Posts: 542
Joined: Aug 31, 2012
Location: Boston, MA

Re: Native States

I spoke too soon. I noticed the behavior again. Any help is appreciated, I cant seem to figure this out.

Note: I've forked the GhostXML plugin for this.

Steps to reproduce:
1. Create a new device of type "GhostXML_RGBWdevice"
2. Add the device settings. Click Save.
3. Error appears in the log:

Code: Select all
 
Error (client)                  illegal state key brightnessLevel defined by plugin -- native state keys cannot be overriden (ignoring)
   Error (client)                  illegal state key onOffState defined by plugin -- native state keys cannot be overriden (ignoring)


Device.XML:
Code: Select all
<?xml version="1.0"?>
<!-- TODO: Note that, depending on the changes made, changes made to the string type device will also need to be made to the real type device. -->
<Devices>

    <Device type="dimmer" id="GhostXML_RGBWdevice">
        <Name>GhostXML RGBW Device</Name>

        <ConfigUI>
            <SupportURL>https://github.com/IndigoDomotics/GhostXML/wiki/devices</SupportURL>

            <!-- FeedType -->

            <Field id="settingsLabel" type="label" fontSize="small">
                <Label>Provide the feed type (XML or JSON), the frequency of data refreshes, and the source URL.</Label>
            </Field>

            <Field id="feedType" type="menu" defaultValue="XML" tooltip="The type of feed you will be using.">
                <Label>Feed Type:</Label>
                <List>
                    <Option value="JSON">JSON</Option>
                    <Option value="XML">XML</Option>
                </List>
            </Field>

            <!-- RefreshFrequency -->

            <Field id="refreshFreq" type="menu" defaultValue="300" tooltip="How often this feed should refresh.">
                <Label>Refresh Frequency:</Label>
                <List>
                    <Option value="0">Manual refresh</Option>
                    <Option value="15">15 Seconds</Option>
                    <Option value="30">30 Seconds</Option>
                    <Option value="60">1 Minute</Option>
                    <Option value="120">2 Minutes</Option>
                    <Option value="300">5 Minutes</Option>
                    <Option value="900">15 Minutes</Option>
                    <Option value="3600">1 Hour</Option>
                    <Option value="14400">4 Hours</Option>
                    <Option value="86400">1 Day</Option>
                </List>
            </Field>

            <!-- Timeout -->

            <Field id="timeout" type="textfield" defaultValue="5" tooltip="Enter the number of seconds that the plugin should continue to try this source before giving up (integer).">
                <Label>Timeout:</Label>
            </Field>

            <Field id="maxRetries" type="textfield" defaultValue="10" tooltip="Enter the maximum number of retries before the plugin automatically disables the device (integer).">
                <Label>Max Retries:</Label>
            </Field>

            <Field id="disableLogging" type="checkbox" defaultValue="false" tooltip="Check the box to disable SQL Plugin logging for all states belonging to this device.">
                <Label>Disable SQL Logging:</Label>
            </Field>

            <!-- URL -->

            <Field id="sourceXML" type="textfield" tooltip="Enter the path to your data source using the examples below as a guide. If you use substitutions, be sure to include the proper variable index in the form of [A], [B], etc.">
                <Label>URL/Path:</Label>
            </Field>

            <Field id="label1" type="label" fontSize="small" alignWithControl="true">
                <Label>Examples:&#xA;URL: http://www.ip_address.com/filename.xml&#xA;URL: https://www.ip_address.com/filename.xml&#xA;URL: ftp://www.ip_address.com/filename.xml&#xA;Local file: file:///folder_path/filename.json</Label>
            </Field>

            <!-- Authentication -->

            <Field id="authTitle" type="label" alignText="right">
                <Label>Authentication</Label>
            </Field>

            <Field id="authSep" type="separator"/>

            <Field id="authLabel" type="label" fontSize="small">
                <Label>If your source requires authentication, select type of authentication used, and enter the username, password or token URL as required.</Label>
            </Field>

            <!-- Note: although this field is called 'useDigest' it's value supports all
            manner of authentication -->
            <Field id="useDigest" type="menu" defaultValue="None" tooltip="Select the appropriate authentication type for your data source.">
                <Label>Method:</Label>
                <List>
                    <Option value="Basic">Basic</Option>
                    <Option value="Digest">Digest</Option>
                    <Option value="Raw">Raw Curl (Advanced)</Option>
                    <Option value="Token">Token</Option>
                    <Option value="-1">%%separator%%</Option>
                    <Option value="None">None</Option>
                </List>
            </Field>

            <!-- Note: although the username and password fields are called digestUser and
            digestPass, these fields are now used for both digest and basic auth. -->
            <Field id="tokenUrl" type="textfield" tooltip="Enter the URL for the Token server." visibleBindingId="useDigest" visibleBindingValue="Token">
                <Label>Token URL:</Label>
            </Field>

            <Field id="digestUser" type="textfield" tooltip="Enter or paste a Username ID here." visibleBindingId="useDigest" visibleBindingValue="Basic, Digest">
                <Label>Username:</Label>
            </Field>

            <Field id="digestPass" type="textfield" tooltip="Enter or paste a Password ID here." visibleBindingId="useDigest" visibleBindingValue="Basic, Digest, Token">
                <Label>Password:</Label>
            </Field>

            <!-- Raw Curl -->
            <Field id="curlArray" type="textfield" tooltip="Please enter your curl commands, which will be appended to the url above." visibleBindingId="useDigest" visibleBindingValue="Raw">
                <Label>Curl Commands:







                </Label>
            </Field>

            <Field id="rawCurlLabel" type="label" fontSize="small" alignWithControl="true" visibleBindingId="useDigest" visibleBindingValue="Raw">
                <Label>Enter the raw curl commands as either a continuous string (no quotes) or line-separated with a space and a backslash to escape each linebreak. Use OPTION/Return to move to the next line.</Label>
            </Field>

            <Field id="rgbwTitle" type="label" alignText="right">
                <Label>RGBW Properties</Label>
            </Field>

            <!-- RGB Device -->

            <Field type="separator" id="simpleSeparator1" />
            <Field type="checkbox" id="SupportsRGB" defaultValue="true">
                <Label>Supports RGB:</Label>
                <Description>Shows RGB control and level fields in UI</Description>
            </Field>
            <Field type="separator" id="simpleSeparator2" />
            <Field type="checkbox" id="SupportsWhite" defaultValue="true">
                <Label>Supports White:</Label>
                <Description>Shows White level fields in UI</Description>
            </Field>
            <Field type="checkbox" id="SupportsTwoWhiteLevels" defaultValue="false" enabledBindingId="SupportsWhite">
                <Label>Supports White 2:</Label>
                <Description>Shows Two White level fields in UI</Description>
            </Field>
            <Field type="label" id="whiteInfoField" fontColor="darkgray" fontSize="small">
                <Label>Two white level fields are used by some hardware to mix cool and warm white levels. Other hardware provides this capability by using a white temperature value. The two techniques are mutually exlcusive, so choosing to enable two white levels will override (and not show) the white temperature UI.</Label>
            </Field>
            <Field type="checkbox" id="SupportsWhiteTemperature" defaultValue="false" enabledBindingId="SupportsWhite" visibleBindingId="SupportsTwoWhiteLevels" visibleBindingValue="false" alwaysUseInDialogHeightCalc="true">
                <Label>Supports White Temp:</Label>
                <Description>Shows White Temperature field in UI</Description>
            </Field>
            <Field type="textfield" id="WhiteTemperatureMin" defaultValue="1200" visibleBindingId="SupportsWhiteTemperature" visibleBindingValue="true" alwaysUseInDialogHeightCalc="true">
                <Label>Minimum White Temperature:</Label>
                <Description>Minimum White Temperature used on UI controls</Description>
            </Field>
            <Field type="textfield" id="WhiteTemperatureMax" defaultValue="6500" visibleBindingId="SupportsWhiteTemperature" visibleBindingValue="true" alwaysUseInDialogHeightCalc="true">
                <Label>Maximum White Temperature:</Label>
                <Description>Maximum White Temperature used on UI controls</Description>
            </Field>

            <!-- Substitutions -->

            <Field id="subTitle" type="label" alignText="right">
                <Label>Substitutions</Label>
            </Field>

            <Field id="subSep" type="separator"/>

            <Field id="subLabel" type="label" fontSize="small">
                <Label>If you would like to use variable substitutions in your feed's URL, tick the Use Substitutions box and enter the variable ID numbers and add the corresponding substitution index to the feed's URL above.</Label>
            </Field>

            <Field id="doSubs" type="checkbox" defaultValue="false" tooltip="Would you like to use substitutions in this feed? Checking the box turns them on and unchecking the box turns them off.">
                <Label>Use substitutions?:</Label>
                <!--<Description>Would you like to use variable substitutions in this feed's URL?</Description>-->
            </Field>

            <Field id="subA" type="textfield" tooltip="Enter or paste a variable ID here (ID number only)." visibleBindingId="doSubs" visibleBindingValue="true">
                <Label>Variable A:</Label>
            </Field>

            <Field id="subB" type="textfield" tooltip="Enter or paste a variable ID here (ID number only)." visibleBindingId="doSubs" visibleBindingValue="true">
                <Label>Variable B:</Label>
            </Field>

            <Field id="subC" type="textfield" tooltip="Enter or paste a variable ID here (ID number only)." visibleBindingId="doSubs" visibleBindingValue="true">
                <Label>Variable C:</Label>
            </Field>

            <Field id="subD" type="textfield" tooltip="Enter or paste a variable ID here (ID number only)." visibleBindingId="doSubs" visibleBindingValue="true">
                <Label>Variable D:</Label>
            </Field>

            <Field id="subE" type="textfield" tooltip="Enter or paste a variable ID here (ID number only)." visibleBindingId="doSubs" visibleBindingValue="true">
                <Label>Variable E:</Label>
            </Field>

            <Field id="subExample" type="label" fontSize="small" alignWithControl="true" visibleBindingId="doSubs" visibleBindingValue="true">
                <Label>Examples:&#xA;URL: http://www.ip_address.com/[A].xml&#xA;Local file: file:///[A]/[B].json</Label>
            </Field>

        </ConfigUI>

        <States>

<!-- IMPORTANT! If a new device state is added here, it must also be added to deviceStartComm (Audit Device States) -->
            <State id="deviceIsOnline">
                <ValueType>Boolean</ValueType>
                <TriggerLabel>Device Online?</TriggerLabel>
                <ControlPageLabel>Device Online?</ControlPageLabel>
            </State>

            <State id="deviceLastUpdated">
                <ValueType>String</ValueType>
                <TriggerLabel>Device Last Updated</TriggerLabel>
                <ControlPageLabel>Device Last Updated</ControlPageLabel>
            </State>

            <State id="deviceTimestamp">
                <ValueType>Integer</ValueType>
                <TriggerLabel>Device Timestamp</TriggerLabel>
                <ControlPageLabel>Device Timestamp</ControlPageLabel>
            </State>

            <State id="parse_error">
                <ValueType>Boolean</ValueType>
                <TriggerLabel>Parse Error</TriggerLabel>
                <ControlPageLabel>Parse Error</ControlPageLabel>
            </State>

        </States>

    </Device>


</Devices>


Posted on
Mon Sep 07, 2020 8:11 am
DaveL17 offline
User avatar
Posts: 5909
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Native States

A possibility --> if you're relying on external XML (or JSON), then the plugin could be trying to create the conflicting state dynamically. Look at your source payload to see if there's a node called 'brightnessLevel' (or whatever's conflicting) and trap for that. All you'd need to do is replace 'brightnessLevel' with 'brightnessLevelX' or something similar.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Mon Sep 07, 2020 8:38 am
vtmikel offline
Posts: 542
Joined: Aug 31, 2012
Location: Boston, MA

Re: Native States

DaveL17 wrote:
A possibility --> if you're relying on external XML (or JSON), then the plugin could be trying to create the conflicting state dynamically. Look at your source payload to see if there's a node called 'brightnessLevel' (or whatever's conflicting) and trap for that. All you'd need to do is replace 'brightnessLevel' with 'brightnessLevelX' or something similar.


Really like your plugin, it's saved me a bunch of time. Assuming I get over this error, will be in touch about a pull request.

I did think about that, and I've confirmed there's no conflicting state keys. My source JSON is below.

But, this does make me wonder, your plugin overrides the base instance of getDeviceStateList. that method appends additional states to that list. For a Custom device type does this behave differently since there are no native states?

Code: Select all
    def getDeviceStateList(self, dev):
        """
        Assign data keys to device state names (Indigo)

        The getDeviceStateList() method pulls out all the keys in self.finalDict and
        assigns them to device states. It returns the modified stateList which is then
        written back to the device in the main thread. This method is automatically
        called by

            stateListOrDisplayStateIdChanged()

        and by Indigo when Triggers and Control Pages are built. Note that it's not
        possible to override Indigo's sorting of devices states which will present them
        as A, B, a, b.

        -----

        :param dev:
        :return state_list:
        """

        # This statement goes out and gets the existing state list for dev from Devices.xml.
        # It seems like it's calling itself, but the structure was recommended by Matt:
        # https://forums.indigodomo.com/viewtopic.php?f=108&t=12898#p87456
        state_list = indigo.PluginBase.getDeviceStateList(self, dev)

        # ========================= Custom States as Strings ==========================
        if dev.deviceTypeId == 'GhostXMLdevice':
            # If there are no managed devices, return the existing states.
            if dev.id not in self.managedDevices.keys():
                for key in dev.states:
                    dynamic_state = self.getDeviceStateDictForStringType(unicode(key), unicode(key), unicode(key))
                    state_list.append(dynamic_state)

            # If there are managed devices, return the keys that are in finalDict.
            else:
                for key in sorted(self.managedDevices[dev.id].finalDict.keys()):
                    dynamic_state = self.getDeviceStateDictForStringType(unicode(key), unicode(key), unicode(key))
                    state_list.append(dynamic_state)

        # ======================== Custom States as True Type =========================
        #
        # 2019-12-18 DaveL17 -- Reconfigured to allow for the establishment of other device state types (int, float, bool, etc.)
        #
        if dev.deviceTypeId == 'GhostXMLdeviceTrue' or dev.deviceTypeId == 'GhostXML_RGBWdevice':

            # If there are no managed devices, return the existing states.
            if dev.id not in self.managedDevices.keys():
                for key in dev.states:
                    dynamic_state = self.getDeviceStateDictForStringType(unicode(key), unicode(key), unicode(key))
                    state_list.append(dynamic_state)

            # If there are managed devices, return the keys that are in finalDict.
            else:
                for key in sorted(self.managedDevices[dev.id].finalDict.keys()):
                    value = self.managedDevices[dev.id].finalDict[key]
                    try:
                        # Integers
                        _ = int(value)
                        state_list.append(self.getDeviceStateDictForNumberType(unicode(key), unicode(key), unicode(key)))
                    except (TypeError, ValueError):
                        try:
                            # Floats
                            _ = float(value)
                            state_list.append(self.getDeviceStateDictForNumberType(unicode(key), unicode(key), unicode(key)))
                        except (TypeError, ValueError):
                            try:
                                # Bools - we create a state for the original data (in string form) and for the boolean representation.
                                if value.lower() in ('on', 'off', 'open', 'locked', 'up', 'armed', 'closed', 'unlocked', 'down', 'disarmed'):
                                    state_list.append(self.getDeviceStateDictForBoolOnOffType(unicode(key), unicode(key), unicode(key)))
                                    state_list.append(self.getDeviceStateDictForBoolOnOffType(unicode(u"{0}_bool".format(key)), unicode(u"{0}_bool".format(key)), unicode(u"{0}_bool".format(key))))
                                elif value.lower() in ('yes', 'no'):
                                    state_list.append(self.getDeviceStateDictForBoolYesNoType(unicode(key), unicode(key), unicode(key)))
                                    state_list.append(self.getDeviceStateDictForBoolYesNoType(unicode(u"{0}_bool".format(key)), unicode(u"{0}_bool".format(key)), unicode(u"{0}_bool".format(key))))
                                elif value.lower() in ('true', 'false'):
                                    state_list.append(self.getDeviceStateDictForBoolTrueFalseType(unicode(key), unicode(key), unicode(key)))
                                    state_list.append(self.getDeviceStateDictForBoolTrueFalseType(unicode(u"{0}_bool".format(key)), unicode(u"{0}_bool".format(key)), unicode(u"{0}_bool".format(key))))
                                else:
                                    state_list.append(self.getDeviceStateDictForStringType(unicode(key), unicode(key), unicode(key)))
                            except (AttributeError, TypeError, ValueError):
                                state_list.append(self.getDeviceStateDictForStringType(unicode(key), unicode(key), unicode(key)))

        return state_list


When I restore your plugin's original device types to the Devices.XML, and add a realXML device using the same source URL, I do not get the illegal state key errors. The only static wites to onOffState and brightnessLevel in the plugin.py source is using the updateStateOnServer method. I added these to support the RGB device type.

The source JSON for my device is:
Code: Select all
{
  "active_mode": "none",
  "alias": "Server Rack Light",
  "ctrl_protocols": {
    "name": "Linkie",
    "version": "1.0"
  },
  "description": "Kasa Smart Light Strip, Multicolor",
  "dev_state": "normal",
  "deviceId": "8012350FA58E795379DA8F6E5BFFACC01D1009B7",
  "disco_ver": "1.0",
  "err_code": 0,
  "hwId": "375D4CCE7C909516CFD57BA93A304404",
  "hw_ver": "1.0",
  "is_color": 1,
  "is_dimmable": 1,
  "is_factory": false,
  "is_variable_color_temp": 1,
  "latitude_i": xxxx,
  "length": 16,
  "light_state": {
    "dft_on_state": {
      "brightness": 100,
      "color_temp": 0,
      "hue": 37,
      "mode": "normal",
      "saturation": 29
    },
    "on_off": 0
  },
  "lighting_effect_state": {
    "brightness": 100,
    "custom": 0,
    "enable": 0,
    "id": "bwTatyinOUajKrDwzMmqxxJdnInQUgvM",
    "name": "Christmas"
  },
  "longitude_i": -xxx,
  "mic_mac": "xxxx",
  "mic_type": "IOT.SMARTBULB",
  "model": "KL430(US)",
  "oemId": "xxxx",
  "preferred_state": [],
  "rssi": -51,
  "status": "new",
  "sw_ver": "1.0.10 Build 200522 Rel.104340"
}

Posted on
Mon Sep 07, 2020 8:48 am
DaveL17 offline
User avatar
Posts: 5909
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Native States

Thanks. Glad you found something in there that could help you. IIRC, the purpose of overriding getDeviceStateList was to control for the condition where the source payload became unavailable for a short time. This caused the device to lose all its states, creating headaches until the source came back online. As I recall, what we do is grab a copy of the existing device states which we can reuse if need be (so the device will always have states). So if I'm thinking about this the right way, you could be pulling the 'existing' brightness level from the dimmer type which could very well cause problems when rewriting the states to dev. You may be on to something since you're using a native device type.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Wed Sep 09, 2020 7:20 am
vtmikel offline
Posts: 542
Joined: Aug 31, 2012
Location: Boston, MA

Re: Native States

Hey Matt - any thoughts on whether the getDeviceStateList override is causing the problem?

Posted on
Wed Sep 09, 2020 8:05 am
matt (support) offline
Site Admin
User avatar
Posts: 20569
Joined: Jan 27, 2003
Location: Texas

Re: Native States

Not sure, but seems possible. Try commenting it out and see?

Image

Posted on
Wed Sep 09, 2020 12:33 pm
vtmikel offline
Posts: 542
Joined: Aug 31, 2012
Location: Boston, MA

Re: Native States

Commenting the function out breaks the GhostXML plugin completely in ways that are beyond my skill.

I have been monitoring the getDeviceStateList(self, dev) function. Specifically, the output of this statement (comments are from DaveL17's plugin)

Code: Select all
        # This statement goes out and gets the existing state list for dev from Devices.xml.
        # It seems like it's calling itself, but the structure was recommended by Matt:
        # https://forums.indigodomo.com/viewtopic.php?f=108&t=12898#p87456
        state_list = indigo.PluginBase.getDeviceStateList(self, dev)


It appears that msot of the time, state_list contains just the custom states from Devices.XML. There are some occasions in which it also contains the native states. DaveL17's plugin had custom device types, so it did not encounter this problem in the past. I cannot figure out the conditions in which it is adding the native states.

I verified by adding:

Code: Select all
        ignore_state_list = ["onOffState", "brightnessLevel", "blueLevel", "greenLevel", "redLevel", "whiteLevel", "whiteTemperature"]


I then check this list before proceeding and skip the native states before allowing the GhostXML to do it's work. I believe the error comes from when the GhostXML plugin tries to re-add the native states using some typecasting.

I'm monitoring to see if this corrects the odd behavior.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests