Tuya LOCAL with energy monitoring and without tuya-convert

I would expect that you emulate that via light and use brightness for dimmer functionality.

Has ony one got this to work

Ive got the ID and localkey Local Tuya finds the devices (Nedis Power Plug with Powerconsuption) Ive added them to IOT Tuya like discrebed (som where)

Tried it with Tuya installed and with out and same result

I whant to extract the power cosnuption

Any tips

localtuya:

  • host: 192.168.86.102
    device_id: xxx
    local_key: xxx
    friendly_name: Tuya_Outside_Light_2
    protocol_version: “3.1”
    entities:

    • platform: light
      friendly_name: Outside_Light_2
      id: 1
      brightness: 1
      brightness_lower: 25
      brightness_upper: 255
  • host: 192.168.86.201
    device_id: xxxx
    local_key: xxxx
    friendly_name: Tuya_Dimmer_Switch
    protocol_version: “3.3”
    entities:

    • platform: light
      friendly_name: Dimmer_Switch
      id: 1
      brightness: 1
      #brightness_lower: 25
      #brightness_upper: 255

These get me me the ability to turn on the Light and switch. They both show that there is a dimming option in the entity. But neither actually dim function in the entity effect the device. I get on/off which is definitely better then where I was the other day but not all the way there :(… I have tried a plethora of numbers against the brightness DPS value.

As a foot note… I have 2 versions of Home assistant running, one is Hass.Io in a Vm and one is a containerized Hass install. In neither of these can I get the integration wizard method to work, I’ve had to edit the configuration.yaml file so I have not really had an opportunity to look at the expected values for the entities. Where can I find them in the localtuya folder? I am really enjoying playing with this integration and I would love to help at a lower level. I am going to be buying a bunch of stuff frpom Menards today (Motion sensor, door sensor, security camera) and maybe some stuff from Walmart (Merkury Brand) and see if they work differently. I hope my problems are not brand specific! I just remembered something actually in the tuya app when i click on the light I get an error “the current version does not support the device. Please update the app” Of course my Tuya App is completely up to date…

I also just figured out, not sure if anyone else knew this or not… the encryption key changes if you re-add a device back into your Tuya App…

Third thing I noticed, my Feit Dimmer Switch, from inside the Tuya app, actually brings up a Feit screen to manipulate the Dimmer function… is that relevant? I cannot now connect to my dimmer anymore after pairing it again to the Tuya app… I have changed my configuration.yaml to reflect the new encryption key. I also have an error now in the TinyTuya program:

Traceback (most recent call last):
File “/usr/lib/python3.7/runpy.py”, line 193, in _run_module_as_main
main”, mod_spec)
File “/usr/lib/python3.7/runpy.py”, line 85, in _run_code
exec(code, run_globals)
File “/home/shane/.local/lib/python3.7/site-packages/tinytuya/main.py”, line 44, in
tinytuya.scan(color=color)
File “/home/shane/.local/lib/python3.7/site-packages/tinytuya/init.py”, line 1087, in scan
d = deviceScan(True, maxretry, color)
File “/home/shane/.local/lib/python3.7/site-packages/tinytuya/init.py”, line 1139, in deviceScan
client.bind(("", UDPPORT))
OSError: [Errno 98] Address already in use

I read that I need to make sure I am logged out of the Tuya app I did that and I shut down my Tuya IoT page so I don’t know where i am going wrong… It did pull the DeviceID’s and Encryption Key’s

HA is also giving me this error:
Logger: homeassistant
Source: runner.py:99
First occurred: 3:05:05 PM (1 occurrences)
Last logged: 3:05:05 PM

Error doing job: Unclosed connection

I have a problem with 1 WiFi plugg it looks like this in HA


I can controll it via Tyua Code in yamal
- host: 192.168.167.36
local_key:
device_id:
friendly_name: MysRummet
protocol_version: “3.3”
entities:
- platform: switch
friendly_name: MysRummet
id: 1
current: 18
current_consumption: 19
voltage: 20
- platform: sensor
friendly_name: MysRummet Current
id: 18
unit_of_measurement: ‘mA’
- platform: sensor
friendly_name: MysRummet Current Consumption
id: 19
scaling: 0.1
unit_of_measurement: ‘W’
- platform: sensor
friendly_name: MysRummet Voltage
id: 20
scaling: 0.1
unit_of_measurement: ‘V’

I also have 2 more WiFi pluggs (same brand) and they are working
Code in yamal

  • host: 192.168.167.33
    local_key:
    device_id:
    friendly_name: TV
    protocol_version: “3.3”
    entities:
    - platform: switch
    friendly_name: TV
    id: 1
    current: 18
    current_consumption: 19
    voltage: 20
    - platform: sensor
    friendly_name: TV Current
    id: 18
    unit_of_measurement: ‘mA’
    - platform: sensor
    friendly_name: TV Användning
    id: 19
    scaling: 0.1
    unit_of_measurement: ‘W’
    - platform: sensor
    friendly_name: TV Voltage
    id: 20
    scaling: 0.1
    unit_of_measurement: ‘V’

They are the same except ofc ID and key and IP Adress

What im i missing?

Thought I’d put this into the thread before adding it as a stand alone addon:

I’ve created a HASSOS addon which, with an api id/key, device id and region will query the Tuya API and provide a locally accessible file with all of your device Names, Ids and Keys

I just got sick of having to login to my ubuntu server to run the command.

This is very much a work in progress and currently it will query the API every 5 minutes when the Addon is running.

The addon is on my repo https://github.com/wlatic/hassio.addons

There are going to be issues, but hopefully with feed back, I can iron them out. Also someone may be able to take this and run with it!

4 Likes

I’d love to give this add-on a try. I added the repository, but the Tuyagrab add-on doesn’t show up to install.
Seeing this error in the logs:
Can’t read json from /data/addons/git/367cd613/addon-tuyagrab/tuyagrab/config.json: Expecting value: line 30 column 10 (char 566)

Because im an idiot. Added in a line just before leaving the house and it duplicated another line! Should be good now.

No worries! I got it installed now, and it worked great! Much easier than hunting for all the values every time and trying to remember where I installed tyua-cli.

Took me a minute to realize that the list would be spit out to file (should have read eh documentation the first time!). Would be nice if it could go to the log as well, but that is a very minor gripe.

I originally had it going to the log and wanted something that people could have open at the same time as they were adding the device. Was an easy edit though, so pushed 0.2 with it going to both the file and the log!

Happy its helped someone other than myself!

Awesome, just updated and tried it out, and looks great! I think this will help simplify the whole process for a lot of people.

This worked amazingly, took me barely any time - you are a genius

100% not! this is just using all the hard work from https://pypi.org/project/tinytuya/ and then packaging it with some simple scripts. I was thinking that the addon should run for 15 minutes and then shut down.

Would that be better than manually stopping it?

I think 15 minutes is a good idea

Added two config items, shutdown time and update time.

by default they do 300 seconds update (5 mins) and 900 seconds shutdown (15 mins) [by default the script adds 60 seconds to the shutdown to make it easier to judge the updates vs shutdowns.

Hi guys, i’m trying to add an RGB strip led by tuya local. I’ve read the documentation but i can’t find anything about dp id 101 102 and 106 that i’ve. What are? So an other question, because my strip led have music mode, so i select it in entity configuration but it gives me back an error? Thanks a lot.

Hi everybody, we have just published a new release to celebrate the end of this f**king year:

If any of you were using the “fake” positioning mode for cover, please make sure you read the Release Notes VERY carefully, since now it has been renamed to “timed” (a much more appropriate name).
Thanks again for the almighty @postlund for his work, plus to @ultratoto14 who became a main collaborator, and all others who contributed.
Happy New Year to everybody, and stay safe… maybe we are seeing the end of the tunnel.

5 Likes

hi @rospogrigio, thank you all.
Unfortunately the new version brought a small problem. My two Teckin SP22 smartplugs have become ‘unavailable’.
The other seven smartplugs I own (six Bakibo TP22Y and one Gosund doubleplug SP211) continue to work very well with HA.
I activated the ‘debug’ function inside the ‘logs’ and I can see something strange. I will open a ticket on github shortly.
Happy New Year to you all and thank you for your work

1 Like

I also have the same problem with 4 Nooie smartplugs not found any more with latest version so I had to downgrade.

Are they on a different VLAN?