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

Hass.states.set api reference

$
0
0

@joff wrote:

Hi.
Is there an api reference for the hass.states.set python procedure.
I am trying to set a sensor using a python script but keep getting syntax errors. I am sure it’s something simple but seeing some documentation on it would be a great help.

I have a template sensor to hold a power total in kWh and am trying to set it with the following:

hass.states.set(output_id, {‘week_total’: “10.5”, ‘unit_of_measurement’: “kWh”, ‘friendly_name’: “Plug Weekly Total”})

(‘output_id’ is a variable entered as service call data when calling the script and defines the entity)

The sensor is defined in my configuration as:

# Sensor to read weekly power consumption of smart plug
  - platform: template
    sensors:
      smart_plug_weekly_total:
        friendly_name: "Plug Weekly Total"
        unit_of_measurement: kWh
        value_template: "{{ attribute('week_total') | float }}"

Any help greatly appreciated.

Posts: 4

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 95409

Trending Articles



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