rospogrigio / localtuya

local handling for Tuya devices
GNU General Public License v3.0
2.83k stars 544 forks source link

Cannot use decimal scaling factor (eg. 0.1) when setting up through UI #609

Open B-Hartley opened 2 years ago

B-Hartley commented 2 years ago

The problem

Cannot use decimal scaling when setting up through UI.

Environment

Steps to reproduce

  1. Add a new integration, when adding a new sensor, attempt to put in scaling factor of 0.1
  2. it won't accept this as it seems to be expecting an integer

Configuration configuration.yaml or config_flow

Succesfully setup using YAML.

localtuya:
  - host: !secret tuya_bar_ip
    device_id: !secret tuya_bar_device_id
    local_key: !secret tuya_bar_local_key
    friendly_name: Tuya Bar
    protocol_version: "3.3"
    entities:
      - platform: sensor
        friendly_name: Tuya Bar Formaldehyde
        id: 2
        scaling: 0.1
        unit_of_measurement: "mg/m3"
      - platform: sensor
        friendly_name: Tuya Bar Temperature
        id: 18
        scaling: 0.1
        device_class: temperature
        unit_of_measurement: "°C" 
      - platform: sensor
        friendly_name: Tuya Bar Humidity
        id: 19
        scaling: 0.1
        device_class: humidity
        unit_of_measurement: "%"
      - platform: sensor
        friendly_name: Tuya Bar VOC
        id: 21
        device_class: volatile_organic_compounds
        unit_of_measurement: "ppm"       
      - platform: sensor
        friendly_name: Tuya Bar CO2
        id: 22
        device_class: carbon_dioxide
        unit_of_measurement: "ppm"

DP dump

Provide Home Assistant taceback/logs

Additional information

Checked for previously raised issue, couldn't find one ?

joshpirihi commented 2 years ago

Same issue here. I found a workaround by typing something non-numeric (eg "n"), then it changes that to NaN. You can append 0.1 to that, then backspace the NaN part leaving 0.1 in there

jkdobro commented 2 years ago

I found a workaround. In Notepad write 0.1 and Copy/Past to setting field.

robhellstrom commented 2 years ago

I had 7 temperature/humidity sensors and they all had a scaling of 1 but needed 0.1. I used the @joshpirihi workaround successfully on all. It works on all but one which remains unavailable despite sensor rebooting. However it worked after HA Server restart.

asd2003ru commented 2 years ago

workaround input 0.1 then press LEFT key on keyboard and enter number.

ionultd commented 2 years ago

@B-Hartley I have a Smart Air Box from AliExpress Tuya based. I believe it may be the same as yours as it has all the same sensors. Setting it up in local Tuya does not appear to get all the sensors. Does your YAML code solve this ?

testxp28 commented 1 month ago

Hello, I have the same problem, Docker platform, I have access to the HA folder via SMB, where can I find the file to edit?