I have a lot of common sensors for plant information. All that information is in mqtt. Instead of creating 100+ sensors one for each plant in the greenhouse I would like to have a single generic sensor for output and modification. Otherwise the data is just sitting out there in mqtt land. To do this I need to be able to read a topic via script or automation to move specific plant data to the generic display sensor.
Currently each plant would require
In confiuration file:
mqtt: !include_dir_merge_list entities/plants
Then each plant has a yaml file:
- sensor:
- name: "mint"
state_topic: "plant/mint"
unique_id: "mint"
icon: "mdi:sprout-outline"
value_template: "{{value_json.common_name}}"
json_attributes_topic: "plant/mint"
json_attributes_template: "{{ value_json | tojson }}"
And each plant has mqtt data:
data:
topic: plant/mint
qos: 0
retain: true
payload: >
water: {{date}}
fert: {{date}}
common name: {{common name}}
—— other payload …
This is working BUT I DON’T WANT 100s of sensors/devices
How can I pull data that exists in a mqtt topic and fill in a generic sensor for viewing and editing?
Reading mqtt data at will via script or automation is what I don’t know how to do.