rospogrigio / localtuya

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

Gosund EP2 plug - current consumption not available #468

Closed Ro4cHii closed 3 years ago

Ro4cHii commented 3 years ago

The problem

I bought two Gosund EP2 smart plugs from Amazon and was able to integrate them into Home Assistant with the help of the manual. Using the "configuration.yaml sample" found in the README, I can see the status and use the switch to toggle the plug, however the current consumption shows "not available".

The Gosund EP2's Product Key is wifvoilfrqeo6hvu - so not included in the list of known working devices. There seem to be less DPs with this specific device:

Environment

Steps to reproduce

  1. Integrate Gosund EP2 smart plug into HA via configuration.yaml or via config flow - doesn't matter

Configuration configuration.yaml or config_flow

localtuya:
  - host: 192.168.178.50
    device_id: 'x'
    local_key: 'y'
    friendly_name: Smart Socket 1
    protocol_version: "3.3"
    entities:
      - platform: binary_sensor
        friendly_name: Plug 1 Status
        id: 1
        device_class: power
        state_on: "true" # Optional
        state_off: "false" # Optional
      - platform: binary_sensor
        friendly_name: Plug 1 DP7
        id: 7
        state_on: "true" # Optional
        state_off: "false" # Optional
      - platform: sensor
        friendly_name: Plug 1 Voltage
        id: 6
        scaling: 0.1 # Optional
        device_class: voltage # Optional
        unit_of_measurement: "V" # Optional
      - platform: sensor
        friendly_name: Plug 1 DP2
        id: 2
        scaling: 0.1 # Optional
      - platform: sensor
        friendly_name: Plug 1 DP4
        id: 4
        scaling: 0.1 # Optional
      - platform: sensor
        friendly_name: Plug 1 DP5
        id: 5
        scaling: 0.1 # Optional
      - platform: switch
        friendly_name: Plug 1
        id: 1
        current: 18 # Optional
        current_consumption: 19 # Optional
        voltage: 6 # Optional
  - host: 192.168.178.56
    device_id: 'x'
    local_key: 'y'
    friendly_name: Smart Socket 2
    protocol_version: "3.3"
    entities:
      - platform: binary_sensor
        friendly_name: Plug 2 Status
        id: 1
        device_class: power
        state_on: "true" # Optional
        state_off: "false" # Optional
      - platform: sensor
        friendly_name: Plug 2 Voltage
        id: 20
        scaling: 0.1 # Optional
        device_class: voltage # Optional
        unit_of_measurement: "V" # Optional
      - platform: switch
        friendly_name: Plug 2
        id: 1
        current: 18 # Optional
        current_consumption: 19 # Optional
        voltage: 20 # Optional
logger:
  default: warning
  logs:
    custom_components.localtuya: debug

DP dump

Unfortunately I was not able to get the tool to run but I guess the DPs are shown when adding entities via config flow!? Gosund_EP2_config-flow

There does not seem to be a reasonable DP for the current consumption, only for the voltage.

Gosund_EP2_entities-card

EDIT: I was trying out the DP dump tool (test.py) on my tower PC before, however I got it to work now via Wifi on my laptop. It doesn't really seem to be quite helpful though. Could the problem maybe be something like that there might be a new firmware version (newer than 3.1 and 3.3)?

$ winpty python test.py x 192.168.178.56 y
INFO:localtuya:localtuya version 1.0.0
INFO:localtuya:Python 3.9.4 (tags/v3.9.4:1f2e308, Apr  4 2021, 13:27:16) [MSC v.
1928 64 bit (AMD64)] on win32
INFO:localtuya:Using pytuya version '8.1.0'
INFO:localtuya:Detecting list of available DPS of device x [1
92.168.178.56], protocol 3.3.
DEBUG:localtuya.pytuya:Sending command status (device type: type_0a)
DEBUG:localtuya.pytuya:paylod=b'{"gwId":"x","devId":"33670367
70039f60a9fa"}'
DEBUG:localtuya.pytuya:DATA RECEIVED!
DEBUG:localtuya.pytuya:decode payload=b'\xc43\x0f\x90\x08\x01N!\xe59\x92\xad\xed
$\x1f;\xc8\xbe\x83\xd0O\xd13#<\xbaB\x00+K`M'
DEBUG:localtuya.pytuya:'data unvalid' error detected: switching to dev_type 'typ
e_0d'
DEBUG:localtuya.pytuya:Re-send status due to device type change (type_0a -> type
_0d)
DEBUG:localtuya.pytuya:Sending command status (device type: type_0d)
DEBUG:localtuya.pytuya:paylod=b'{"devId":"x","uid":"336703677
0039f60a9fa","t":"1619693029","dps":{"1":null,"2":null,"3":null,"4":null,"5":nul
l,"6":null,"7":null,"8":null,"9":null,"10":null}}'
DEBUG:localtuya.pytuya:Failed to connect to 192.168.178.56. Raising Exception.
WARNING:localtuya.pytuya:Failed to get status: timed out
INFO:localtuya:Detecting list of available DPS of device x [1
92.168.178.56], protocol 3.3.
DEBUG:localtuya.pytuya:Sending command status (device type: type_0a)
DEBUG:localtuya.pytuya:paylod=b'{"gwId":"x","devId":"33670367
70039f60a9fa"}'
DEBUG:localtuya.pytuya:DATA RECEIVED!
DEBUG:localtuya.pytuya:decode payload=b'\xc43\x0f\x90\x08\x01N!\xe59\x92\xad\xed
$\x1f;\xc8\xbe\x83\xd0O\xd13#<\xbaB\x00+K`M'
DEBUG:localtuya.pytuya:'data unvalid' error detected: switching to dev_type 'typ
e_0d'
DEBUG:localtuya.pytuya:Re-send status due to device type change (type_0a -> type
_0d)
DEBUG:localtuya.pytuya:Sending command status (device type: type_0d)
DEBUG:localtuya.pytuya:paylod=b'{"devId":"x","uid":"336703677
0039f60a9fa","t":"1619693039","dps":{"1":null,"2":null,"3":null,"4":null,"5":nul
l,"6":null,"7":null,"8":null,"9":null,"10":null}}'
DEBUG:localtuya.pytuya:Failed to connect to 192.168.178.56. Raising Exception.
WARNING:localtuya.pytuya:Failed to get status: [WinError 10054] Eine vorhandene
Verbindung wurde vom Remotehost geschlossen
INFO:localtuya:Detecting list of available DPS of device x [1
92.168.178.56], protocol 3.3.
DEBUG:localtuya.pytuya:Sending command status (device type: type_0a)
DEBUG:localtuya.pytuya:paylod=b'{"gwId":"x","devId":"33670367
70039f60a9fa"}'
DEBUG:localtuya.pytuya:Failed to connect to 192.168.178.56. Raising Exception.
WARNING:localtuya.pytuya:Failed to get status: [WinError 10054] Eine vorhandene
Verbindung wurde vom Remotehost geschlossen
INFO:localtuya:TIMEOUT: No response from device x [192.168.17
8.56] after 2 attempts.

Provide Home Assistant taceback/logs

Log file attached

home-assistant.log

Additional information

In my FritzBox, I put both devices on the black list for internet access. Today, when I first tested them, I initially linked them with the Gosund Android app. There, the current consumption was shown correctly.

Ro4cHii commented 3 years ago

The solution to this problem is described in #470.