Tuya LOCAL with energy monitoring and without tuya-convert

Current, voltage, and current consumption appear as attributes of the switch.

Works fine for me with this code in configuration.yaml.
DPS [1] VALUE [True]
DPS [9] VALUE [0]
DPS [18] VALUE [32] - Š”urrent
DPS [19] VALUE [32] - Power
DPS [20] VALUE [2367] - Voltage
DPS [21] VALUE [1]
DPS [22] VALUE [691]
DPS [23] VALUE [33766]
DPS [24] VALUE [20628]
DPS [25] VALUE [2030]
DPS [26] VALUE [0]
DPS [38] VALUE [memory] - Relay Status [off; on; memory]
DPS [40] VALUE [relay]
DPS [41] VALUE [False] - Lock
DPS [42] VALUE []
DPS [43] VALUE []
DPS [44] VALUE []

- host: 192.168.1."""
    device_id: """""""""""""""
    local_key: """"""""""""""""
    friendly_name: Computer socket  local tuya
    protocol_version: "3.3"
    scan_interval: 15
    entities:
      - platform: switch
        friendly_name: Computer socket  local tuya
        id: 1
        current: 18
        current_consumption: 19
        voltage: 20
      - platform: sensor
        friendly_name: Current Computer socket  local tuya
        id: 18
        scaling: 0.001
        device_class: current
        unit_of_measurement: "A"
      - platform: sensor
        friendly_name: Power Computer socket  local tuya
        id: 19
        scaling: 0.1
        device_class: power
        unit_of_measurement: "W"
      - platform: sensor
        friendly_name: Voltage Computer socket  local tuya
        id: 20
        scaling: 0.1
        device_class: voltage
        unit_of_measurement: "V"
	  - platform: select
        friendly_name: Relay Status
        id: 38
        select_options: off; on; memory
        select_options_friendly: OFF; ON; Remember last status
	  - platform: switch
        friendly_name: Child Lock
        id: 41

3 Likes

You have to add, again under ā€œintegrationsā€ ā€¦choose Local_Tuya find the device in the dropdownlist, click add, then add sensor , choose 18 and add, then same last steps for 19 and 20 (add sensor choose 19, then 20), then you get them ass individual sensors( find them in entities-list after), beside the ā€œviewā€ (attributes) you have under the Switch

2 Likes

Hi,
I would like to integrate a Smartlife Aromatherapy Machine, but I donā€™t know how to integrate it.

It has both the ignition switch, the possibility of varying the humidifier (normal / large), varying the color of the LED, switching on 1h, 3h, 6h.

In tuya IOT it is identified as:
ā€œcategory_nameā€: ā€œHumidifierā€,
ā€œmodelā€: ā€œ13Kā€,
ā€œproduct_nameā€: ā€œAromatherapy machineā€

Has anyone managed to integrate it?

Do you have any information about this questions? Iā€™ve same question

Hi,

How can i add second host? I have 3 smart plug

Scroll just 3 posts upwards of yours ā€¦ :crazy_face:

1 Like

May I ask how you setup the EP2ā€™s with Local Tuya?

I have a PR for better Fan support; I am using it with a REPHO air filter.

The current code assumes all sensors are numbers, and will do stack dumps on everything else.. .

Same issue for me. Is there any update?

Itā€™s not worked for me. Is it still working for you?

Just go to intgreations and use local-tuya

Yes

1 Like

I asked in the Local Tuya github repo if itā€™s possible to add other scaling factors different from 0.1? E.G. 0.01, 0.001, etc. in the UI config flow.
At the moment only the 0.1 value is possible:

159168022-e62bb742-7e29-438a-9f4b-6ccb4b7b8a16

This limitation forces to have mA instead of A in current values and Wh instead of KWh in energy readings:

159168113-4351a2f8-50d7-4a27-b1de-216ea15ff1ac

Adding my experience. I too acquired the Gosund SP1 hoping for ESP but sadly it was the RT chip so ā€˜forcedā€™ to use localtuya, which creates the switch and its attributes. Then I created a template sensor to have the ā€˜stateā€™ current_consumption and also added a intergation sensor based on the previous to create the statistics. Clearly horrible to have 3 entries to get to the Energy dashboard but it is as it is.

  - platform: template
    sensors:
      gosund_1_consumption:
        friendly_name: "GosundPlug1 current consumption"
        unit_of_measurement: 'W'
        device_class: power
        value_template: "{{ states.switch.gosundplug1.attributes.current_consumption }}"
  - platform: integration
    source: sensor.gosund_1_consumption
    name: gosund_plug_1
    method: left
    round: 2
    unit_prefix: k

Im not sure about your specific Device, but All my devices in Local-Tuya, i had to Click again, on ADD-Integration, choose Local-Tuya ( and in the drop-down, choose the specific Device ) Then You Choose, Other than ID_1, (if you click the drop-down there, you should choose ā€œSensorā€) then you should get another dropdown, with atleast ID_18,ID_19,ID_20) ā€¦ (dont forget to ā€œuncheckā€ the little box, to be able to continue adding IDā€™s, otherwise you have to choose ADD Integration again ( a little ā€œnotā€ intuitive interface, and if you do/choose wrong , you have to start from scratch again(no go back, and change) :slight_smile:
PS: You actually donā€™t have to choose , to have these 3 as Attributes

In Tuya.iot you can get a complete spec. on your Devices, with all itā€™s ā€œoptions/settingsā€ as which IDā€™s it have, and which scale you should use(cording to themā€¦ not always right)(i.e scale 1 == scaling-factor 0.1

Work for for my Nedis and Deltaco devices, but again i donā€™t know about Gosund

You can use what ever you like, just type i.e. 0.001 in text-editor, then copy-paste to overwrite 0.1

Yesā€¦ localtuya creates the main switch, indiviaulaly/manually
Added (!) to that, the two I mentioned above.I was hoping to just create the ā€˜integrationā€™ one on top of localtuya but I seem to need the ā€˜templateā€™ to get the consumption data into state-valueā€¦allowing the ā€˜integrationā€™ to create statistics
So
switch.gosundplug (localtuya) => sensor.gosundplug_consumption (template) <+sensor.gosundplug_stats(integration)

Yes, either a template-sensor, or ā€œaddingā€ the specific Sensor in Tuya-Integration ( either way, another sensor) :slight_smile: , to base the statistic-sensor ā€œcalculationā€ on

text not finished but just to be clear: you too need 3 (!) entities ?