Log error what it takes to fix it?

Logger: homeassistant.util.logging
Source: util/logging.py:108
First occurred: November 16, 2020, 9:57:17 PM (14235 occurrences)
Last logged: 9:11:22 AM

  • Exception in state_message_received when handling msg on ‘tele/smartmeter/SENSOR’: ‘{“Time”:“2020-11-17T03:09:17”,“ENERGY”:{“TotalStartTime”:“2020-10-28T07:10:33”,“Total”:0.043,“Yesterday”:0.002,“Today”:0.001,“Period”:0,“Power”:230,“ApparentPower”:300,“ReactivePower”:192,“Factor”:0.77,“Frequency”:50,“Voltage”:232,“Current”:1.290}}’ Traceback (most recent call last): File “/usr/local/lib/python3.8/site-packages/hatasmota/sensor.py”, line 222, in state_message_received state = get_value_by_path(msg.payload, self._cfg.value_path) File “/usr/local/lib/python3.8/site-packages/hatasmota/utils.py”, line 168, in get_value_by_path return get_by_path(status, path) File “/usr/local/lib/python3.8/site-packages/hatasmota/utils.py”, line 37, in get_by_path return reduce(operator.getitem, items, root) TypeError: ‘float’ object is not subscriptable
  • Exception in state_message_received when handling msg on ‘stat/smartmeter/STATUS8’: ‘{“StatusSNS”:{“Time”:“2020-11-17T03:10:12”,“ENERGY”:{“TotalStartTime”:“2020-10-28T07:10:33”,“Total”:0.043,“Yesterday”:0.002,“Today”:0.001,“Power”:236,“ApparentPower”:308,“ReactivePower”:198,“Factor”:0.77,“Frequency”:50,“Voltage”:232,“Current”:1.326}}}’ Traceback (most recent call last): File “/usr/local/lib/python3.8/site-packages/hatasmota/sensor.py”, line 225, in state_message_received state = get_value_by_path(msg.payload, value_path) File “/usr/local/lib/python3.8/site-packages/hatasmota/utils.py”, line 168, in get_value_by_path return get_by_path(status, path) File “/usr/local/lib/python3.8/site-packages/hatasmota/utils.py”, line 37, in get_by_path return reduce(operator.getitem, items, root) TypeError: ‘int’ object is not subscriptable

Can you share the mqtt sensor associated with ‘tele/smartmeter/SENSOR’?

sensor:
- platform: mqtt
  name: "SmartMeter-Voltage"
  state_topic: "tele/smartmeter/SENSOR"
  value_template: '{{ value_json["ENERGY"]["Voltage"] }}'
  unit_of_measurement: "voltage"
- platform: mqtt
  name: "SmartMeter-Current"
  state_topic: "tele/smartmeter/SENSOR"
  value_template: '{{ value_json["ENERGY"]["Current"] }}'
  unit_of_measurement: "amps"  
- platform: mqtt
  name: "SmartMeter-Power"
  state_topic: "tele/smartmeter/SENSOR"
  value_template: '{{ value_json["ENERGY"]["Power"] }}'
  unit_of_measurement: "W"  
- platform: mqtt
  name: "SmartMeter-TODAY"
  state_topic: "tele/smartmeter/SENSOR"
  value_template: '{{ value_json["ENERGY"]["Today"] }}'
  unit_of_measurement: "kWh"
- platform: mqtt
  name: "SmartMeter-Yesterday"
  state_topic: "tele/smartmeter/SENSOR"
  value_template: '{{ value_json["ENERGY"]["Yesterday"] }}'
  unit_of_measurement: "kWh"
- platform: mqtt
  name: "SmartMeter-ApparentPower"
  state_topic: "tele/smartmeter/SENSOR"
  value_template: '{{ value_json["ENERGY"]["ApparentPower"] }}'
  unit_of_measurement: "VA"
- platform: mqtt
  name: "SmartMeter-Total"
  state_topic: "tele/smartmeter/SENSOR"
  value_template: '{{ value_json["ENERGY"]["Total"] }}'
  unit_of_measurement: "kWh"

Are any of the listed sensors working?

Tried restarting home assistant to see what happens?

My entry for a sonoff s31…

- platform: mqtt
  name: "Sonoff S31 Watts"
  state_topic: "tele/sonoff_s31/SENSOR"
  value_template: "{{ value_json['ENERGY'].Power }}"
  unit_of_measurement: "Watts"
  availability_topic: "tele/sonoff_s31/LWT"
  qos: 1
  payload_available: "Online"
  payload_not_available: "Offline"

#Edit

So I pasted this into the template editor (json from tasmota console)…

{% set value_json =
{“Time”:“2020-11-17T07:06:55”,“ENERGY”:{“TotalStartTime”:“2020-11-15T11:36:11”,“Total”:0.799,“Yesterday”:0.109,“Today”:0.035,“Period”:0,“Power”:13,“ApparentPower”:20,“ReactivePower”:15,“Factor”:0.65,“Voltage”:121,“Current”:0.161}}
%}

Both of the below work to extract Power

{{ value_json['ENERGY']['Power'] }}
{{ value_json['ENERGY'].Power }}

I’d say change…

value_template: '{{ value_json["ENERGY"]["ApparentPower"] }}'

to…

value_template: "{{ value_json['ENERGY']['Power'] }}"


yes now working

Tried restarting home assistant to see what happens?

Is the last log entry of the error the time home assistant started after restarting?

yes after restart

Happy to see the entities working! Not sure about the error though.

I’m not sure if there is a connection. In the log console StatusSNS shows two times.

I don’t know why the console is displaying the status messages??

The output of my s31 is…

21:40:06 MQT: tele/sonoff_s31/STATE = {"Time":"2020-11-17T21:40:06","Uptime":"5T15:47:07","UptimeSec":488827,"Heap":25,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":6,"POWER":"OFF","Wifi":{"AP":1,"SSId":"HA-DEMO","BSSId":"74:44:01:44:39:26","Channel":11,"RSSI":100,"Signal":-30,"LinkCount":6,"Downtime":"0T00:00:31"}}
21:40:06 MQT: tele/sonoff_s31/SENSOR = {"Time":"2020-11-17T21:40:06","ENERGY":{"TotalStartTime":"2020-11-15T11:36:11","Total":0.837,"Yesterday":0.109,"Today":0.073,"Period":0,"Power":0,"ApparentPower":0,"ReactivePower":0,"Factor":0.00,"Voltage":0,"Current":0.000}}

Which show up at intervals based on the teleperiod option.

Do you have an automation that sends the command “cmd/smartmeter/status 0” to the tasmota device or a rule defined in tasmota?

See this thread >>>

Hi
did you solve the problem?

I’ve the same behaviour with my pzem-016 tasmotized.
(even if console is just a bit different, log is the same, and it leads my home-assistant.log to grow VERY fast)

My problem persists And I still can’t find a way out. Now I have moved to esphome and the log is very clean.

I think I solved this way:
in Settings - Devices, I’ve found my “PowerMonitor” and disabled all entities but just a few (energy_today, energy_total, energy_totalstarttime, energy_yesterday)
(Even if I suppose I could disable ALL entities…)

Now errors are gone, so log file doesn’t grow anymore

1 Like