I’m a total noob when it comes down to templates and already got stuck at the first go.
I read a value via the rest platform. This correctly resturn a ‘value’ (I can see this nicely in the interface). As HAss does not know what it is,m it does not track historic value etc. So I want to use a template to show actual Watts (numeric value).
I have below code. In the log I find: homeassistant.components.sensor.template: UndefinedError: ‘None’ has no attribute ‘state’.
I’m sure its something stupid!
sensor p1elec:
platform: rest
resource: http://192.168.1.5:3480/data_request?id=variableget&DeviceNum=266&serviceId=urn:micasaverde-com:serviceId:EnergyMetering1&Variable=Watts
method: GET
name: Watts
sensor kWtemplate:
- platform: template
sensors:
energy_meter:
value_template: "{{ states.sensor.p1elec.state | round(1) }}"
friendly_name: Energy Meter
unit_of_measurement: 'kW'
@PtP I originally use your template (with the multiply(0.001)) but this yields the same result.
The REST is pulling fine (and displays nicely in the interface) but the template does not work (just shows a - instead of a number).
So I think the REST pulls a text string (therefore also not logging the value to make a graph) which I need converted into a number. As such I only need a 1:1 conversion to number as I want to show Watts and not Kw (like you do)