tuya-local icon indicating copy to clipboard operation
tuya-local copied to clipboard

(R5093 Smart Light Strip) TypeError: unsupported operand type(s) for *: 'int' and 'NoneType'

Open MartinCarbol opened this issue 3 years ago • 1 comments

Hi,

I'm using R5093 Smart Light Strip (7raeccy3ar12nn9x) with Tuya-local integration.

The service light/turn_on returns an error when I'm trying to switch the LED strip on. Sometimes it works well but then many times in a row not.

Please see the log.

Logger: homeassistant
Source: custom_components/tuya_local/helpers/device_config.py:544 
Integration: Tuya Local (documentation, issues) 
First occurred: 29. Sep 2022 22:14:21 (60 occurrences) 
Last logged: 20:56:12

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 812, in _update_entity_states
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 520, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 573, in _async_write_ha_state
    attr.update(self.state_attributes or {})
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 933, in state_attributes
    data[ATTR_COLOR_TEMP] = self.color_temp
  File "/config/custom_components/tuya_local/generic/light.py", line 96, in color_temp
    unscaled = self._color_temp_dps.get_value(self._device)
  File "/config/custom_components/tuya_local/helpers/device_config.py", line 325, in get_value
    return self._map_from_dps(device.get_property(self.id), device)
  File "/config/custom_components/tuya_local/helpers/device_config.py", line 544, in _map_from_dps
    result = -1 * result + r["min"] + r["max"]
TypeError: unsupported operand type(s) for *: 'int' and 'NoneType'

Device specs:

{
  "result": {
    "category": "dj",
    "functions": [
      {
        "code": "switch_led",
        "lang_config": {
          "false": "OFF",
          "true": "ON"
        },
        "name": "Switch",
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "work_mode",
        "lang_config": {
          "colour": "White",
          "music": "Music",
          "scene": "Scene",
          "white": "Color"
        },
        "name": "Mode",
        "type": "Enum",
        "values": "{\"range\":[\"white\",\"colour\",\"scene\",\"music\"]}"
      },
      {
        "code": "bright_value_v2",
        "lang_config": {
          "unit": ""
        },
        "name": "Bright",
        "type": "Integer",
        "values": "{\"unit\":\"\",\"min\":10,\"max\":1000,\"scale\":0,\"step\":1}"
      },
      {
        "code": "colour_data_v2",
        "lang_config": {
          "unit": ""
        },
        "name": "Color ",
        "type": "Json",
        "values": "{\"h\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":360,\"step\":1},\"s\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":1000,\"step\":1},\"v\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":1000,\"step\":1}}"
      },
      {
        "code": "scene_data_v2",
        "lang_config": {
          "unit": ""
        },
        "name": "Scene",
        "type": "Json",
        "values": "{\"scene_num\":{\"min\":1,\"scale\":0,\"max\":8,\"step\":1},\"scene_units\": {\"unit_change_mode\":{\"range\":[\"static\",\"jump\",\"gradient\"]},\"unit_switch_duration\":{\"min\":0,\"scale\":0,\"max\":100,\"step\":1},\"unit_gradient_duration\":{\"min\":0,\"scale\":0,\"max\":100,\"step\":1},\"bright\":{\"min\":0,\"scale\":0,\"max\":1000,\"step\":1},\"temperature\":{\"min\":0,\"scale\":0,\"max\":1000,\"step\":1},\"h\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":360,\"step\":1},\"s\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":1000,\"step\":1},\"v\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":1000,\"step\":1}}}"
      },
      {
        "code": "countdown_1",
        "lang_config": {
          "unit": "s"
        },
        "name": "Left time",
        "type": "Integer",
        "values": "{\"unit\":\"\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "control_data",
        "lang_config": {
          "unit": ""
        },
        "name": "Debugger",
        "type": "Json",
        "values": "{\"change_mode\":{\"range\":[\"direct\",\"gradient\"]}, \"bright\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":1000,\"step\":1}, \"temperature\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":1000,\"step\":1}, \"h\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":360,\"step\":1},\"s\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":255,\"step\":1},\"v\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":255,\"step\":1}}"
      }
    ],
    "status": [
      {
        "code": "switch_led",
        "lang_config": {
          "false": "OFF",
          "true": "ON"
        },
        "name": "Switch",
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "work_mode",
        "lang_config": {
          "colour": "White",
          "music": "Music",
          "scene": "Scene",
          "white": "Color"
        },
        "name": "Mode",
        "type": "Enum",
        "values": "{\"range\":[\"white\",\"colour\",\"scene\",\"music\"]}"
      },
      {
        "code": "bright_value_v2",
        "lang_config": {
          "unit": ""
        },
        "name": "Bright",
        "type": "Integer",
        "values": "{\"unit\":\"\",\"min\":10,\"max\":1000,\"scale\":0,\"step\":1}"
      },
      {
        "code": "colour_data_v2",
        "lang_config": {
          "unit": ""
        },
        "name": "Color ",
        "type": "Json",
        "values": "{\"h\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":360,\"step\":1},\"s\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":1000,\"step\":1},\"v\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":1000,\"step\":1}}"
      },
      {
        "code": "scene_data_v2",
        "lang_config": {
          "unit": ""
        },
        "name": "Scene",
        "type": "Json",
        "values": "{\"scene_num\":{\"min\":1,\"scale\":0,\"max\":8,\"step\":1},\"scene_units\": {\"unit_change_mode\":{\"range\":[\"static\",\"jump\",\"gradient\"]},\"unit_switch_duration\":{\"min\":0,\"scale\":0,\"max\":100,\"step\":1},\"unit_gradient_duration\":{\"min\":0,\"scale\":0,\"max\":100,\"step\":1},\"bright\":{\"min\":0,\"scale\":0,\"max\":1000,\"step\":1},\"temperature\":{\"min\":0,\"scale\":0,\"max\":1000,\"step\":1},\"h\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":360,\"step\":1},\"s\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":1000,\"step\":1},\"v\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":1000,\"step\":1}}}"
      },
      {
        "code": "countdown_1",
        "lang_config": {
          "unit": "s"
        },
        "name": "Left time",
        "type": "Integer",
        "values": "{\"unit\":\"\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "control_data",
        "lang_config": {
          "unit": ""
        },
        "name": "Debugger",
        "type": "Json",
        "values": "{\"change_mode\":{\"range\":[\"direct\",\"gradient\"]}, \"bright\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":1000,\"step\":1}, \"temperature\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":1000,\"step\":1}, \"h\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":360,\"step\":1},\"s\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":255,\"step\":1},\"v\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":255,\"step\":1}}"
      }
    ]
  },
  "success": true,
  "t": 1664565097320,
  "tid": "b4c56c4d40f311edb880ca0f69d78a9e"
}

Thanks for your time.

MartinCarbol avatar Sep 30 '22 19:09 MartinCarbol

Release 0..19.3 contains a fix for the issue indicated in the logs. My guess is that on lights that only return color_temp when in the rgb color mode, this may occur due to lack of data in the info from the light.

make-all avatar Oct 04 '22 13:10 make-all