@febalci wrote:
I have this python script that reads electricity power outages in my neighborhood and prints the result in json format. If there is no planned outages, json comes back as empty, but there might be one or more planned work that causes power outage. I use this command line sensor at the moment:
- platform: command_line name: Gediz Elektrik scan_interval: 3600 json_attributes: - starts_at - ends_at - get_reason - get_zones command: 'python3 external_data/gdzelektrik_outages.py' value_template: '{{ value_json.manuel_zone }}'
I also use an “Entities Card” on the front end. If there is no planned outages, it writes “Unknown”, if there is only one outage, it writes the details on the card, but if there is more than one work, it writes “Unknown” again on the card with log error “Unable to parse output as JSON”
What i try to achieve is:
- If there is no outage (json empty), no card on the frontend
- If there is only one outage (single json), only one card on the frontend
- If there is more than one (dictionary), create as much cards as necessary.
How can i achieve this in a most efficient way?
Posts: 2
Participants: 2