Wrigs
(Wrigs)
May 11, 2024, 2:39pm
1
Hi Guys, I am a Noob at HA and have been experimenting with keeping track of how long my geysers have been on in any 24 hour period and then starting them up again at 4am if they haven’t been heating for at least 3 hours in the past day.
I added Sensors.yaml and addled the !include command in the configuration file.
I can add 1 geyser but as soon as i add the others i get the duplicate key error and only the last one on the list is recognised.
Any advice would be appreciated.
Code from Sensors.yaml below:
platform: history_stats
name: Geyser Domestic ON today
entity_id: switch.geyser_domestic_switch_1
state: “on”
type: time
end: “{{ (now() + timedelta(hours=17)).replace(hour=7, minute=0, second=0, microsecond=0) }}”
duration:
hours: 24
platform: history_stats
name: Geyser Feeder ON today
entity_id: switch.geyser_feeder_switch_1
state: “on”
type: time
end: “{{ (now() + timedelta(hours=17)).replace(hour=7, minute=0, second=0, microsecond=0) }}”
duration:
hours: 24
platform: history_stats
name: Geyser Primary ON today
entity_id: switch.geyser_primary_switch_1
state: “on”
type: time
end: “{{ (now() + timedelta(hours=17)).replace(hour=7, minute=0, second=0, microsecond=0) }}”
duration:
hours: 24
francisp
(Francis)
May 11, 2024, 3:44pm
3
impossible to say with your wrangled code posting, but each sensor should have a - in front of it.
1 Like
Wrigs
(Wrigs)
May 12, 2024, 5:48am
4
Apoligies for the rookie error. I hope this is now pasted with formatting. I suspect i have messed up indentation in the Sensors.yaml file
name: Geyser Domestic ON today
entity_id: switch.geyser_domestic_switch_1
state: "on"
type: time
end: "{{ (now() + timedelta(hours=17)).replace(hour=7, minute=0, second=0, microsecond=0) }}"
duration:
hours: 24
platform: history_stats
name: Geyser Feeder ON today
entity_id: switch.geyser_feeder_switch_1
state: "on"
type: time
end: "{{ (now() + timedelta(hours=17)).replace(hour=7, minute=0, second=0, microsecond=0) }}"
duration:
hours: 24
platform: history_stats
name: Geyser Primary ON today
entity_id: switch.geyser_primary_switch_1
state: "on"
type: time
end: "{{ (now() + timedelta(hours=17)).replace(hour=7, minute=0, second=0, microsecond=0) }}"
duration:
hours: 24```
You are correct. Try using https://www.yamllint.com/ to check your code.
2 Likes
Wrigs
(Wrigs)
May 12, 2024, 6:09am
6
Thank you Guys - The indent and “-” was what it needed.
name: Geyser Domestic ON today
entity_id: switch.geyser_domestic_switch_1
state: "on"
type: time
end: "{{ (now() + timedelta(hours=17)).replace(hour=7, minute=0, second=0, microsecond=0) }}"
duration:
hours: 24
- platform: history_stats
name: Geyser Feeder ON today
entity_id: switch.geyser_feeder_switch_1
state: "on"
type: time
end: "{{ (now() + timedelta(hours=17)).replace(hour=7, minute=0, second=0, microsecond=0) }}"
duration:
hours: 24
- platform: history_stats
name: Geyser Primary ON today
entity_id: switch.geyser_primary_switch_1
state: "on"
type: time
end: "{{ (now() + timedelta(hours=17)).replace(hour=7, minute=0, second=0, microsecond=0) }}"
duration:
hours: 24```