2018-01-25 02:13:16 ERROR (Thread-2) [homeassistant.util.yaml] while parsing a block mapping
in “/home/homeassistant/.homeassistant/sensors.yaml”, line 31, column 5
expected , but found ‘’
in “/home/homeassistant/.homeassistant/sensors.yaml”, line 35, column 38
2018-01-25 02:13:16 ERROR (MainThread) [homeassistant.bootstrap] Error loading /home/homeassistant/.homeassistant/configuration.yaml: while parsing a block mapping
in “/home/homeassistant/.homeassistant/sensors.yaml”, line 31, column 5
expected , but found ‘’
in “/home/homeassistant/.homeassistant/sensors.yaml”, line 35, column 38
Try putting single quotes round it like it shows in the example!
will try to explan
as the MQTT is a Json Message
02:16:38 MQT: tele/sonoff_pow_1/SENSOR = {“Time”:“2018-01-25T02:16:38”,“ENERGY”:{“Total”:0.149,“Yesterday”:0.079,“Today”:0.070,“Period”:0,“Power”:22,“Factor”:0.52,“Voltage”:228,“Current”:0.183}}
think of each { as start of a object and the next { is the child of it
so want to read the
MQTT of the tele/sonoff_pow_1/SENSOR
state_topic: "tele/sonoff_pow_1/SENSOR"
as we want to Read the Yesterday value which is in side the ENERGY { } which is its child
so
value_template: "{{value_json['ENERGY'].Yesterday }}"
so putting it all together
- platform: mqtt
name: Sonoff Pow Yesterday Energy
unit_of_measurement: "kWh"
state_topic: "tele/sonoff_pow_1/SENSOR"
value_template: "{{value_json['ENERGY'].Yesterday }}"
This is mine
- platform: mqtt
name: "Washing Power"
state_topic: "tele/SONOFF-POW1/SENSOR"
value_template: "{{value_json['ENERGY'].Power }}"
qos: 1
unit_of_measurement : "W"
See clear as mud
I can confirm the syntax from @keithh666 works too. This is my setup:
sensor:
- platform: mqtt
name: "SP1_Yesterday"
state_topic: "tele/sonoffpow-1/SENSOR"
value_template: '{{ value_json["ENERGY"]["Yesterday"] }}'
unit_of_measurement: "kWh"
forgot about the 2rd [ ] you use them if you are going to change the data in side the [] with some code to read the data
hope that cents
see clear as mud
hey guys, i’m new to the sonoff pow and need help with calibrating it.
can someone tell me how to calibrate tasmota so it measures the correct values?
Wire it up to a ,60 w light and see what what u get
You need an incandescent bulb (traditional or halogen) to avoid influences from the power factor.
Any idea on how to get Power Factor to show up in Hassio, This doesn’t seem to work
- platform: mqtt
name: “Power Factor”
state_topic: “stat/pow1/STATUS8”
value_template: “{{ value_json[‘StatusPWR’].Factor }}”
This is my configuration:
- platform: mqtt
name: "Sonoff_PowerFactor"
state_topic: "tele/sonoffpow/SENSOR"
value_template: '{{ value_json["ENERGY"]["Factor"] }}'
Thanks! That did the trick!
For those who wanted the mqtt sensor attribute to display correctly. You can use this.
Basically, it read the SENSOR ENERGY and republish as SENSOR_DATA so the mqtt sensor can reach from SENSOR_DATA with all the attribute.
sensor:
- platform: mqtt
name: "SonOffPow1"
state_topic: "tele/sonoffpow1/SENSOR_DATA"
value_template: '{{ value_json.Power }}'
unit_of_measurement: "Watts"
json_attributes:
- Current
- Today
- Yesterday
- Voltage
- Total
Automation:
- alias: 'AutoSonoffPowAtribute'
initial_state: true
#hide_entity: True
trigger:
- platform: mqtt
topic: 'tele/sonoffpow1/SENSOR'
action:
- service: mqtt.publish
data_template:
topic: 'tele/sonoffpow1/SENSOR_DATA'
payload: '{{ trigger.payload_json.ENERGY | tojson }}'
YES here is mine
- platform: mqtt
name: “POW Current”
state_topic: “tele/sonoff_pool_pump/SENSOR”
value_template: “{{ value_json[‘ENERGY’].Current }}”
unit_of_measurement: ‘amps’ - platform: mqtt
name: “POW Power”
state_topic: “tele/sonoff_pool_pump/SENSOR”
value_template: “{{ value_json[‘ENERGY’].Power }}”
unit_of_measurement: ‘watts’ - platform: mqtt
name: “POW Voltage”
state_topic: “tele/sonoff_pool_pump/SENSOR”
value_template: “{{ value_json[‘ENERGY’].Voltage }}”
unit_of_measurement: ‘volts’
Hay bro Can you format it its easyer to read
Good afternoon,
first of all thank you for all the useful information shared on this forum.
This is the first time I write here, I hope my post will be ok.
I have a small issue with sonoff plugs (flashed with tasmota). I was trying to collect data over time in order to calculate the overall energy consumption and costs. The problem is that the total energy sensor behaviour is strange since it is not monotonus (always increasing), as you can see in the attached picture. Maybe this is due to some wifi signal drop, since the wifi signal shows drops at the position of the total energy drop. Maybe I missed some useful information concerning this. Anyway do you have some advises in order to solve this problem? Thank you
Here is the full JSON what you get back from Tasmota 8.3.1 an Sonoff POW R1
{
"Time": "2020-05-27T20:17:30",
"ENERGY": {
"TotalStartTime": "2020-05-27T18:51:48",
"Total": 0.226,
"Yesterday": 0,
"Today": 0.226,
"Period": 1,
"Power": 277,
"ApparentPower": 277,
"ReactivePower": 0,
"Factor": 1,
"Voltage": 218,
"Current": 1.272
}
}
therefore only replace the xxxxx to get all 11 parameters
for example also TotalStartTime
value_template: '{{ value_json["ENERGY"]["xxxxx"] }}'
btw you can get this JSON output in the HA menu:
Developer Tool > MQTT > Listen to a topic > and enter your topic like
tele/YOUR-TASMOTA-NAME/SENSOR
YOUR-TASMOTA-NAME == what you entered in your tasmota configuration for MQTT