Hi, i am trying to establish my location detection more effective way by using the ping method and assign to device tracker.
The PING code in binary_sensors.yaml are as follows
# Ping
- platform: ping
host: 192.168.0.124
name: Rama_Ping
scan_interval: 30
count: 1
- platform: ping
host: 192.168.0.243
name: James_Ping
scan_interval: 30
count: 1
- platform: ping
host: 192.168.0.59
name: Dilan_Ping
scan_interval: 30
count: 1
The device_tracker.yaml code as follows
- platform: mqtt
devices:
rama_note8: 'location/rama'
james_a7: 'location/james'
dilan_note5: 'location/dilan'
qos: 1
payload_home: 'Marat-Office'
payload_not_home: 'Away'
In automations.yaml
- alias: Update location
trigger:
- platform: state
entity_id:
- binary_sensor.rama_ping
- binary_sensor.dilan_ping
- binary_sensor.james_ping
condition: []
action:
- service: mqtt.publish
data_template: >
{% if is_state('binary_sensor.rama_ping', 'on') %}
topic: 'location/rama'
payload_home: 'Marat-Office'
{% elif is_state('binary_sensor.rama_ping','off') %}
topic: 'location/rama'
payload_not_home: 'Away'
{% if is_state('binary_sensor.dilan_ping', 'on') %}
topic: 'location/dilan'
payload_home: 'Marat-Office'
{% elif is_state('binary_sensor.dilan_ping','off') %}
topic: 'location/dilan'
payload_not_home: 'Away'
{% if is_state('binary_sensor.james_ping', 'on') %}
topic: 'location/james'
payload_home: 'Marat-Office'
{% elif is_state('binary_sensor.james_ping','off') %}
topic: 'location/james'
payload_not_home: 'Away'
{% endif %}
mode: single
While i monitor MQTT explore, there is no changes take place. Please do advice