zhcong / homeassistant-atHome

homeassistant check at home with arp ping and mqtt.
Mozilla Public License 2.0
1 stars 0 forks source link

homeassistant-atHome

check at home status with arp ping and mqtt in homeassistant. principle are follows:

principle

you should create a crontab with linux service.

*  *  *  *  * /usr/bin/python3 /opt/atHome.py

and follow those step:
1 change ip of your phone.

phoneList = ['192.168.1.204']

2 change mqtt service address.

broker = '192.168.1.1'
port = 1883

3 change mqtt topic.

haConfigTopic = "homeassistant/switch/leaveCheck1/config"
haConfig = '{ "unique_id": "%s", "name": "%s", "state_topic": "home/%s/state", "command_topic": "home/%s/set", ' \
           '"payload_on": "ON", "payload_off": "OFF" }' % (
               'leaveCheck1', '离家检测器', 'leaveCheck1', 'leaveCheck1')

haStateTopic = 'home/%s/state' % 'leaveCheck1'
haSetTopic = 'home/%s/set' % 'leaveCheck1'

it works perfect. work