So obvious now! Try #84 and see if it works.
Hi @postlund ,
I tried #84 (https://github.com/rospogrigio/localtuya-homeassistant/pull/84),
the bulbs can be controlled but the brightness cannot be raised to the maximum and I saw that in the light.py file there are no attributes to change.
On this occasion I tried to configure my sonoff too, but I still can’t integrate it. This is the log:
2020-10-15 11:24:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [MyID] Started heartbeat loop
2020-10-15 11:24:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [MyID] Sending command heartbeat (device type: type_0a)
2020-10-15 11:24:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [MyID] Paylod: b’{}’
2020-10-15 11:24:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [MyID] Waiting for sequence number -100
2020-10-15 11:24:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [MyID] Sending command status (device type: type_0a)
2020-10-15 11:24:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [MyID] Paylod: b’{“gwId”:“MyID”,“devId”:“MyID”}’
2020-10-15 11:24:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [MyID] Waiting for sequence number 1
2020-10-15 11:24:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [MyID] Got heartbeat response
2020-10-15 11:24:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [MyID] Decode payload: b’’
2020-10-15 11:24:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [MyID] Decrypted payload: {}
2020-10-15 11:24:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [MyID] Dispatching sequence number 1
2020-10-15 11:24:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [MyID] Decode payload: b’\xbb\x0c\xd2\xcb@,\r\xc6;\x07s\xef\x8e*:\x0b\xe5\x07J\xee\xfe\x1c{\x08G=K\te0Jk’
2020-10-15 11:24:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [MyID] switching to dev_type type_0d
2020-10-15 11:24:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [MyID] Re-send status due to device type change (type_0a -> type_0d)
2020-10-15 11:24:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [MyID] Sending command status (device type: type_0d)
2020-10-15 11:24:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [MyID] Paylod: b’{“devId”:“MyID”,“uid”:“MyID”,“t”:“1602753851”,“dps”:{“1”:null,“2”:null,“3”:null,“4”:null,“5”:null,“6”:null,“7”:null,“8”:null,“9”:null,“10”:null}}’
2020-10-15 11:24:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [MyID] Waiting for sequence number 2
2020-10-15 11:24:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [MyID] Dispatching sequence number 2
2020-10-15 11:24:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [MyID] Decode payload: b’’
2020-10-15 11:24:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [MyID] Decrypted payload: {}
2020-10-15 11:24:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [MyID] Sending command status (device type: type_0d)
2020-10-15 11:24:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [MyID] Paylod: b’{“devId”:“MyID”,“uid”:“MyID”,“t”:“1602753851”,“dps”:{“1”:null,“11”:null,“12”:null,“13”:null,“14”:null,“15”:null,“16”:null,“17”:null,“18”:null,“19”:null,“20”:null}}’
2020-10-15 11:24:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [MyID] Waiting for sequence number 3
2020-10-15 11:24:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [MyID] Dispatching sequence number 3
2020-10-15 11:24:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [MyID] Decode payload: b’’
2020-10-15 11:24:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [MyID] Decrypted payload: {}
2020-10-15 11:24:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [MyID] Sending command status (device type: type_0d)
2020-10-15 11:24:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [MyID] Paylod: b’{“devId”:“MyID”,“uid”:“MyID”,“t”:“1602753851”,“dps”:{“1”:null,“21”:null,“22”:null,“23”:null,“24”:null,“25”:null,“26”:null,“27”:null,“28”:null,“29”:null,“30”:null}}’
2020-10-15 11:24:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [MyID] Waiting for sequence number 4
2020-10-15 11:24:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [MyID] Got status update
2020-10-15 11:24:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [MyID] Dispatching sequence number 4
2020-10-15 11:24:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [MyID] Got status update
2020-10-15 11:24:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [MyID] Decode payload: b’’
2020-10-15 11:24:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [MyID] Decrypted payload: {}
2020-10-15 11:24:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [MyID] Sending command status (device type: type_0d)
2020-10-15 11:24:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [MyID] Paylod: b’{“devId”:“MyID”,“uid”:“MyID”,“t”:“1602753851”,“dps”:{“1”:null,“100”:null,“101”:null,“102”:null,“103”:null,“104”:null,“105”:null,“106”:null,“107”:null,“108”:null,“109”:null,“110”:null}}’
2020-10-15 11:24:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [MyID] Waiting for sequence number 5
2020-10-15 11:24:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [MyID] Dispatching sequence number 5
2020-10-15 11:24:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [MyID] Decode payload: b’’
2020-10-15 11:24:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [MyID] Decrypted payload: {}
2020-10-15 11:24:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [MyID] detected dps: {}
2020-10-15 11:24:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [MyID] Closing connection
2020-10-15 11:24:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [MyID] Connection lost: None
2020-10-15 11:24:11 DEBUG (MainThread) [custom_components.localtuya.pytuya] [MyID] Closing connection
Does anyone know if there is a way to set a static IP address on these energy monitoring smart plugs using the localtuya custom component?
I have a limited number of DHCP leases that can be set on my router and having to re-configure my four smart plugs whenever the router is rebooted can become tedious.
Not possible AFAIK. But I plan on adding auto-discovery during setup, so the IP address will be of no need in that case. This basically means that the integration scans the network for devices and find the IP based on device id.
Sounds like a great solution. Will you post back here when there is news on this?
Sure, I can ping you when I have something to test. I will try to work on it tonight.
This is cool, but it will increase the startup time by 6 secs, can we consider the auto-discovery to be optional? In my setup, my devices have never undergone an IP address change…
Actually, it will not because I will be implementing it in a better way. Leaving that as a cliffhanger…
Did you set correct limits for the brightness ranges here? I might have to add some debug points again to see if it works better. Also, feel free to post future logs in the PR instead so we better can keep track of what’s not working.
Hi @postlund,
in the light.py file of the repository “https://github.com/rospogrigio/localtuya-homeassistant/pull/84” there is no longer the possibility to set the levels for the MIN and MAX attributes.
is this the custom localtuya right?
localtuya-homeassistant-fix_0d_devices
I also tried to put back the repository “https://github.com/rospogrigio/localtuya-homeassistant/pull/80/” file localtuya “localtuya-homeassistant-light_range”, but here I have the problem that I can’t even manage the ON and OFF status even by setting my values 10 / 1000
PS Where do you want me to write the logs to keep track?
I have rebased #80 now, so it shall have all the fixes you need. Please try it out. You can write updates/logs in #80.
That’s perfect!
@rospogrigio I think in general we should ask people to create new issues for bugs and feature requests, rather than take the lengthy discussion here. Any thoughts?
Except for some polishing, I’m done. Would love some input. You can try it out here:
Thanks for your efforts.
Checking it out now.
Something like this will do:
git fetch origin
git checkout origin/discovery_updates
I had it originally installed from the zip file back in early July so my config yaml needs to be re-worked to suit current file structure.
Previously I had
switch:
- platform: localtuya
host: 192.168.1.20
local_key: 0117a0655exxxxxx
device_id: 655256142462abyyyyyy
name: tuya_kitch_01
friendly_name: tuya_kitch_01
protocol_version: 3.3
current: 18
current_consumption: 19
voltage: 20
so now I need:
localtuya:
- host: 192.168.1.20
local_key: 0117a0655exxxxxx
device_id: 655256142462abyyyyyy
friendly_name: Tuya Device
protocol_version: 3.3
entities:
- platform: switch
friendly_name: Kitchen Plug 1
id: 1
current: 18 # Optional
current_consumption: 19 # Optional
voltage: 20
but I am getting invalid config
Invalid config for [switch.localtuya]: required key not provided @ data['device_id']. Got None
required key not provided @ data['friendly_name']. Got None
required key not provided @ data['host']. Got None
required key not provided @ data['local_key']. Got None
required key not provided @ data['name']. Got None. (See ?, line ?).
Is the README.md up to date?
The config looks about right. Just run with id 1 for the moment, usually correct. IP address is to the plug, but try enter another IP address instead. It should hopefully recover, that’s the point.
That error comes from your old switch
config, just remove it.
Edit: README.me in the repo should be ok.
It was getting fussy with me. I needed quotes around the 3.3 in the version line.
Now it is connecting ok and all voltage, current etc. values are reading as well.
Looking good! Great work.
I shall explore the other 2 devices and see if they pick up on change of ip address.