Skip to content

Instantly share code, notes, and snippets.

@maxwellamaral
Forked from maxwellcc/readme.md
Created September 6, 2022 12:35
Show Gist options
  • Save maxwellamaral/cd16f7e68d2a55082e3f134434de7bca to your computer and use it in GitHub Desktop.
Save maxwellamaral/cd16f7e68d2a55082e3f134434de7bca to your computer and use it in GitHub Desktop.
List of Tuya devices with codes for Home Assistant

List of Tuya devices with codes for Home Assistant

On jun/2022 in Home Assistant v. 2022.6

Summary

Smart plug

  1. Smart plug type 1

    • 01 - ID / State of switch --> True/False
    • 09 -
    • 17 -
    • 18 - Current (mA)
    • 19 - Power / Current consumption (W) --> x/10
    • 20 - Voltage (V) --> x/10
    • 21 -
    • 22 -
    • 23 -
    • 24 -
    • 25 -
    • 26 -
    • 38 - (?) --> True/False
  2. Smart plug type 2

    • 01 - ID / State of switch --> True/False
    • 09 -
    • 17 -
    • 18 - Current (mA)
    • 19 - Power / Current consumption (W) --> x/10
    • 20 - Voltage (V) --> x/10
    • 38 - (?) --> True/False
    • 41 -
    • 42 -
    • 43 -

Sensor template example for energy monitoring

For areas in sensors, insert unique_id

Template sensor

# Escritório tomada 2 setup
- platform: template
  sensors:
    escritorio_tomada_2_setup_corrente:
      unique_id: escritorio_tomada_2_setup_corrente
      friendly_name: Escritório tomada 2 setup corrente
      unit_of_measurement: "A"
      value_template: >
        {% set sensor_1 = states.switch.escritorio_tomada_2_setup.attributes.current %}
        {% if is_number(sensor_1) -%}
          {{ float(sensor_1) / 1000 | round(1) }}
        {%- else -%}
          0
        {%- endif %}

    escritorio_tomada_2_setup_tensao:
      unique_id: escritorio_tomada_2_setup_tensao
      friendly_name: Escritório tomada 2 setup tensão
      unit_of_measurement: "V"
      value_template: >
        {% set sensor_1 = states.switch.escritorio_tomada_2_setup.attributes.voltage %}
        {% if is_number(sensor_1) -%}
          {{ float(sensor_1) | round(1) }}
        {%- else -%}
          0
        {%- endif %}

    escritorio_tomada_2_setup_watts:
      unique_id: escritorio_tomada_2_setup_watts
      friendly_name: Escritório tomada 2 setup watts
      unit_of_measurement: "W"
      device_class: power
      value_template: >
        {% set sensor_1 = states.switch.escritorio_tomada_2_setup.attributes.current_consumption %}
        {% if is_number(sensor_1) -%}
          {{ float(sensor_1) | round(2) }}
        {%- else -%}
          0
        {%- endif %}         

Integration sensor

   - platform: integration
     unique_id: escritorio_consumo_total_tomada_2_setup_integracao
     source: sensor.escritorio_tomada_2_setup_watts
     name: Escritório consumo total tomada 2 setup (Integração)
     unit_prefix: k
     round: 3

Utility meter sensor

   # Medições do setup smart
   escritorio_consumo_diario_setup:
     unique_id: escritorio_consumo_diario_setup
     name: Escritório consumo diário Setup
     source: sensor.escritorio_consumo_total_tomada_2_setup_integracao
     cycle: daily

   escritorio_consumo_mensal_setup:
     unique_id: escritorio_consumo_mensal_setup
     name: Escritório consumo mensal Setup
     source: sensor.escritorio_consumo_total_tomada_2_setup_integracao
     cycle: monthly

Light

  1. Light bulb RGB
    • 20 - ID --> True/False
    • 21 - Color Mode --> colour/...
    • 22 - Brightness
    • 23 - Color temperature
    • 24 - Color --> ...
    • 25 - Scene
    • 26 -

Power strip (régua de tomada)

  1. Power strip
    • 01 - Power plug 1
    • 02 - Power plug 2
    • 03 - Power plug 3
    • 04 - Power plug 4
    • 05 - Power plug USB

Star projector (projetor estelar)

  1. Star projector

    # Localtuya does not yet have a proper entity configuration. So I created an adaptation. When adding the projector, configure three lights and a switch as shown below.
    
     - platform: light
       friendly_name: Star Projector - Starlight
       id: 53 # Usually 1 or 20
       brightness: 54 # Optional, usually 3 or 22, default: "none"
       brightness_lower: 10 # Optional, usually 0 or 29, default: 29
       brightness_upper: 1000 # Optional, usually 255 or 1000, default: 1000
    
     - platform: light
       friendly_name: Star projector - Rotation of the stars
       id: 60 # Usually 1 or 20
       brightness: 62 # Optional, usually 3 or 22, default: "none"
       brightness_lower: 1 # Optional, usually 0 or 29, default: 29
       brightness_upper: 100 # Optional, usually 255 or 1000, default: 1000
    
     - platform: switch
       friendly_name: Star projector
       id: 20
    
     - platform: light
       friendly_name: Star projector - Nebula
       id: 52
       # color_mode: 51
       # color: 24 # Optional, usually 5 (RGB_HSV) or 24 (HSV), default: "none"
       
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment