mrk-its / homeassistant-blitzortung

Custom Component for fetching lightning data from blitzortung.org
MIT License
200 stars 39 forks source link

Geolocation events: which source should I use to filter these on the map card? #25

Closed groenmarsmannetje closed 3 years ago

groenmarsmannetje commented 3 years ago

I would like to show a Lovelace map card with the lighting strikes, but to me it is not clear which "geo_location_source" I should use to only display these Blitzortung locations on the map. Please explain.

MrSuttonmann commented 3 years ago

I'm not the author of the software, but I think this line of geo_location.py is key:

coordinator = hass.data[DOMAIN][config_entry.entry_id]

I think the const DOMAIN is the geolocation source id, which in this case is set to blitzortung in const.py.

I'm setting my own map to that to see what happens, but I'm not 100% confident that is the correct value.

image

groenmarsmannetje commented 3 years ago

I have also set it up like that... now have to wait for some thunder storms ;-)

DavidFW1960 commented 3 years ago

I don't think that will work as the integration provides a distance, azimuth and number of strikes. image I have been through this some time ago with this on the forum. You have to make an automation that creates a device tracker from it:

  - id: 'lightning'
    alias: Lightning
    trigger:
    - platform: state
      entity_id: sensor.blitzortung_lightning_azimuth
    condition: 
    - "{{ states('sensor.blitzortung_lightning_counter') | float != 0 }}"
    mode: restart
    action:
    - service: device_tracker.see
      data:
        dev_id: lightning
        gps:
          - "{{ state_attr('sensor.blitzortung_lightning_azimuth', 'lat') }}"
          - "{{ state_attr('sensor.blitzortung_lightning_azimuth', 'lon') }}"

It will then make a device_tracker in known_devices.yaml or you might need to manually create it first..

lightning:
  icon:
  mac:
  name: lightning
  picture:
  track: true

Then you can add to a map card in Lovelace like this:

          - type: map
            show_header_toggle: false
            dark_mode: true
            geo_location_sources:       #these and the sources are optional
              - nsw_rural_fire_service_feed
              - gdacs
            entities:
              - zone.home
              - device_tracker.lightning

Note when there is lightning, it will create a geo_location.lightning* entity but you can't plot it without calling the device.see service... I am actually wondering what will happen here when they finally do kill off known_devices.yaml? @mrk-its

groenmarsmannetje commented 3 years ago

@MrSuttonmann I can confirm that it works. See example of map with lightning strikes in my Home Assistant.

C130D1FF-8B9B-4D78-A1DC-ECE5E95621B9

MrSuttonmann commented 3 years ago

@groenmarsmannetje Awesome! Glad I could help.

Zendio commented 3 years ago

You could also use (in your map card):

geo_location_sources:
  - all

This will show all the geolightning entities without having to turn them into device_trackers.

gaussey commented 1 year ago
  - id: 'lightning'
    alias: Lightning
    trigger:
    - platform: state
      entity_id: sensor.blitzortung_lightning_azimuth
    condition: 
    - "{{ states('sensor.blitzortung_lightning_counter') | float != 0 }}"
    mode: restart
    action:
    - service: device_tracker.see
      data:
        dev_id: lightning
        gps:
          - "{{ state_attr('sensor.blitzortung_lightning_azimuth', 'lat') }}"
          - "{{ state_attr('sensor.blitzortung_lightning_azimuth', 'lon') }}"

your condition syntax is incorrect and doesn’t pass checking, see here examples : https://www.home-assistant.io/docs/scripts/conditions/

z3r0l1nk commented 1 year ago
  - id: 'lightning'
    alias: Lightning
    trigger:
    - platform: state
      entity_id: sensor.blitzortung_lightning_azimuth
    condition: 
    - "{{ states('sensor.blitzortung_lightning_counter') | float != 0 }}"
    mode: restart
    action:
    - service: device_tracker.see
      data:
        dev_id: lightning
        gps:
          - "{{ state_attr('sensor.blitzortung_lightning_azimuth', 'lat') }}"
          - "{{ state_attr('sensor.blitzortung_lightning_azimuth', 'lon') }}"

your condition syntax is incorrect and doesn’t pass checking, see here examples : https://www.home-assistant.io/docs/scripts/conditions/

It passed like this:

alias: Lightning_track
description: ""
trigger:
  - platform: state
    entity_id: sensor.blitzortung_lightning_azimuth
condition:
  - "{{ states('sensor.blitzortung_lightning_counter') | float != 0 }}"
action:
  - service: device_tracker.see
    data:
      dev_id: lightning
      gps:
        - "{{ state_attr('sensor.blitzortung_lightning_azimuth', 'lat') }}"
        - "{{ state_attr('sensor.blitzortung_lightning_azimuth', 'lon') }}"
mode: restart