Platform: history_stats did work

I have problem with platform: history

I have add these lines to sensors.yaml (where I have many other definitions, that works well)

# Filtrace bazénu - doba běhu čerpadla
- platform: history_stats
  entity_id: switch.tasmota_filtrace_bazenu
  name: bazen_filtrace_doba_behu_cerpadla
  state: "on"
  type: time
  start: "{{ now().replace(hour=0, minute=0, second=0, microsecond=0) }}"
  end: "{{ now() }}"

My problem is that this definition is absolutely ignored by latest version of HomeAssistatnt. And I do not know why.

I go to the Developer Tools → States and try to find sensor.bazen_filtrace_doba_behu_cerpadla … no that variable exists

If do automation like this

alias: Filtrace bazénu - automatické vypnutí
description: ""
trigger:
  - platform: numeric_state
    entity_id: sensor.bazen_filtrace_doba_behu_cerpadla
    above: 1
action:
  - service: switch.turn_off
    target:
      entity_id: switch.tasmota_filtrace_bazenu
    data: {}

It do absolutely nothing… It is never triggered.

Can anybody help with why is platform: history_stats definistion ignored ???

No problems since ever, probably your switch.tasmota_filtrace_bazenu ??

I have turn on and turn off

switch.tasmota_filtrace_bazenu

several times manually

And it has no result to

sensor.bazen_filtrace_doba_behu_cerpadla

… because this sensor still didnot exists

did you restart/boot HA? Anything in the logs? If yes + no then maybe set the log level higher on platform level to track any issues

1 Like

Just that first one. No need for a host reboot. Just a restart of Home Assistant.

History stats also depends on registering of history on this entity, right? If there is no history for this entity, stats will not be generated

1 Like

They did say:

So as long as this switch has not been excluded from the recorder there should be some history.

Yes, it has history…

obrazek

But still did not exists

obrazek
(not posible to select from menu)

And finally it did not work…

Automation trase never read sensor… problably because of it still did not exists … and that is because of HA ignores declaration of

- platform: history_stats
  entity_id: switch.tasmota_filtrace_bazenu
  name: bazen_filtrace_doba_behu_cerpadla
  state: "on"
  type: time
  start: "{{ now().replace(hour=0, minute=0, second=0, microsecond=0) }}"
  end: "{{ now() }}"

I cannot see anything in Logbook because there is still no entity bazen_filtrace_doba_behu_cerpadla

Yes, I do… soft or cold reboot of HA I have done several times

Settings → System → Logs. Look for errors related to your sensor.

As I mentioned before… HA completly ignores definition of sensor.bazen_filtrace_doba_behu_cerpadla.

In log is possible to find out this. But it is error log automation… not for… declaration of platform: history_stats >> name: bazen_filtrace_doba_behu_cerpadla

 Logger: homeassistant.components.homeassistant.triggers.numeric_state
Source: components/homeassistant/triggers/numeric_state.py:137
Integration: Home Assistant Core Integration (documentation, issues)
First occurred: July 3, 2023 at 22:33:11 (26 occurrences)
Last logged: 10:54:13

    Error initializing 'websocket_api' trigger: In 'numeric_state' condition: unknown entity sensor.bazen_filtrace_doba_behu_cerpadla
    Error initializing 'websocket_api' trigger: In 'numeric_state' condition: entity switch.tasmota_filtrace_bazenu state 'off' cannot be processed as a number
    Error initializing 'Filtrace bazénu - automaticky vypnutí' trigger: In 'numeric_state' condition: entity switch.tasmota_filtrace_bazenu state 'off' cannot be processed as a number
    Error initializing 'Filtrace bazénu - automatické vypnutí' trigger: In 'numeric_state' condition: entity switch.tasmota_filtrace_bazenu state 'off' cannot be processed as a number
    Error initializing 'Filtrace bazénu - automatické vypnutí' trigger: In 'numeric_state' condition: unknown entity sensor.bazen_filtrace_doba_behu_cerpadla

You should forget about automation and focus on creating your entity first.

Enable debug logging for history stats integration, restart your HA instance and look for debug logs after changing the state of source switch couple of times.

Thanks that helped…

Problem were that in configuration.yaml I included automations.yaml before sensors.yaml

Nope. The order you put integrations in configuration.yaml does not matter. It was something else.

1 Like