Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 105795

Add Custom Sensor to existing Device

$
0
0

Hello everyone,

I bought a Tuya socket with consumption measurement. It works, but the power information is in the attributes and not as separate sensors. I have created sensors for the information I need. However, these are “deviceless” and only exist as entities. Is it possible to add sensors to existing devices, similar to how the BatteryNotes integration does it?

The socket is controlled via LocalTuya.
Sensor Code:

  - platform: template
    sensors:
      waschmaschine_power:
        friendly_name: "Waschmaschine Stromverbrauch"
        unique_id: "waschmaschine_power"
        entity_id: switch.waschmaschine
        value_template: "{{ state_attr('switch.waschmaschine', 'current_consumption') }}"
        unit_of_measurement: 'W'
        #device_class: apparent_power
      waschmaschine_status:
        friendly_name: "Waschmaschine Status"
        unique_id: "waschmaschine_status"
        value_template: >-
          {% set power = states('sensor.waschmaschine_power')|float %}
          {% if power == 0 %}
            aus
          {% elif power > 1 and power < 10 %}
            wartend
          {% elif power > 10 %}
            läuft
          {% endif %}

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 105795

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>