Hi everybody,
I am currently trying to set up an overview for all my tasmota
outlets with energy monitoring. My current file for this is sensors/power_test.yaml
with this content
- platform: mqtt
state_topic: "home/tasmota/tasmota-8833/tele/SENSOR"
name: "(A) Rechner Watt"
value_template: "{{value_json['ENERGY'].Power}}"
qos: 2
unit_of_measurement: "W"
icon: mdi:flash-circle
availability_topic: "home/tasmota/tasmota-8833/tele/LWT"
payload_available: "Online"
payload_not_available: "Offline"
- platform: mqtt
name: "(A) Rechner Volt"
state_topic: "home/tasmota/tasmota-8833/tele/SENSOR"
name: "(A) Rechner Volt"
value_template: "{{value_json['ENERGY'].Voltage}}"
qos: 2
unit_of_measurement: "V"
icon: mdi:flash-circle
availability_topic: "home/tasmota/tasmota-8833/tele/LWT"
payload_available: "Online"
payload_not_available: "Offline"
I want to add sections for this for each value_json I can use, so in my case =>
(cursive values are available, but I might not need them)
- ENERGY.Total
- ENERGY.Yesterday
- ENERGY.Today
- ENERGY.Period
- ENERGY.Power
- ENERGY.ApparentPower
- ENERGY.ReactivePower
- ENERGY.Factor
- ENERGY.Voltage
- ENERGY.Current
I can just write these values block by block, that is fine. However, I donât only have the tasmota-8833
topic (my PC), but also tasmota-xxyy
, tasmota-aabb
, tasmota-you_get_it
, etc.
tl;dr
Can I create a sensor template in which I have something like state_topic: "home/tasmota/tasmota-<VARIABLE>/tele/SENSOR
and name: "<VARIABLE> Watt/Voltage/Today/etc"
, and then specify a list like
- 8833: (A) Rechner
- xxyy: (W) TV
- aabb: (S) TV
So that for each device in this list, home assistant will automatically create each sensor with itâs corresponding name? For example, everything for xxyy
would have state_topic: "home/tasmota/tasmota-xxyy/tele/SENSOR
and name: (W) TV Watt
, name: (W) TV Voltage
, etc.?
I could just manually write a template, then use awk
to create each .yaml
file for this as well⌠But that would mean Iâd have to repeat this for each newly added device as well. If there is a way to âjustâ tell hass âthis is my array of device numbers and their corresponding names, please create a set of sensors from that template file for each one of themâ, it would make it much easier to maintain.
Sorry if this is a naive question. I am fairly new to home assistant and the fact that one needs to restart it after changing the configuration.yaml
(or any file that been !include
ed) plus me always messing up the yaml syntax is making this a bit hard to âjust tryâ.
Btw., same goes for a lot of switches as well as just on/off states that I work with. Currently I control them via node-red
, which allows me to use a template node and just change part of the mqtt topic for each device. They all work with the same payloads, telemetry data, etc. etc. anyway, so I thought maybe there might be a way to save the time writing awk scripts or copy/pasting a lot of similar data and automate the process.
Thanks in advance for your help