HA presence detection, welke AP connected

sky
Premium Member
Premium Member
Berichten: 738
Lid geworden op: 22 Mei 2003
Locatie: Gent
Bedankt: 79 keer
Uitgedeelde bedankjes: 16 keer

HA presence detection, welke AP connected

Berichtdoor sky » 02 Feb 2020, 15:25

Ik heb in home assistant al presence detection via tado en wifi (unifi controller)
Dat werkt perfect. HA geeft per gebruiker mooi weer of die thuis is of niet.
Maar ik zou willen weten op welke AP deze geconnecteerd is. Op internet vind ik niet dadelijk antwoorden.

Gebruikersavatar
Tim.Bracquez
Elite Poster
Elite Poster
Berichten: 3037
Lid geworden op: 05 Dec 2010
Twitter: fusabe
Locatie: ::1
Bedankt: 415 keer
Uitgedeelde bedankjes: 141 keer
Contact:

Re: HA presence detection, welke AP connected

Berichtdoor Tim.Bracquez » 02 Feb 2020, 15:53

Zelf dit in een test omgeving al opgezet met MikroTik en CAPSMAN, daarin werkt dit gewoon (Node-red) op basis van dit: https://community.home-assistant.io/t/m ... -to/150671
73dc3d50a10c0ff301995be701b7ed0246f931e4.jpeg


Met unifi was me dit niet ook direct gelukt (tijdje geleden), dus dit draadje maar eens volgen.
Tim Bracquez, tim@fusa.be, https://www.fusa.be
Dedicated Servers & Promoties - https://fusa.be/nl/hosting/offer
MikroTik Routerboards - https://fusa.be/shop

Gebruikersavatar
devilkin
Elite Poster
Elite Poster
Berichten: 2693
Lid geworden op: 17 Mei 2006
Twitter: jdeluyck
Locatie: Gent
Bedankt: 124 keer
Recent bedankt: 24 keer
Uitgedeelde bedankjes: 265 keer
Contact:

Re: HA presence detection, welke AP connected

Berichtdoor devilkin » 02 Feb 2020, 17:34

Ik heb zoiets gebouwd, en dat werkt... maar het is niet echt vriendelijk als je met veel mensen zit die je wilt tracken.

Ik baseer me op de new_state.attributes.ap_mac, en dus het MAC adres van het AP.

Code: Selecteer alles

[{"id":"3eb38d5e.e59912","type":"inject","z":"a14cb62d.365d4","name":"Study","topic":"","payload":"{\"entity_id\":\"device_tracker.oneplus6\",\"old_state\":{\"state\":\"home\",\"attributes\":{\"ap_mac\":\"xx:xx:xx:xx:xx:xx\"}},\"new_state\":{\"state\":\"home\",\"attributes\":{\"ap_mac\":\"xx:xx:xx:xx:xx:xx\"}}}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":60,"wires":[["3add9afa.c1b24e"]]},{"id":"3add9afa.c1b24e","type":"trigger-state","z":"a14cb62d.365d4","name":"OP6 Tracker","server":"5f01146c.501bec","entityid":"device_tracker.oneplus6","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"id":"m4yph6mr2nm","targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"home"}],"constraintsmustmatch":"all","outputs":4,"customoutputs":[{"outputId":"sikaxqno59","messageType":"payload","messageValue":"livingroom","messageValueType":"json","comparatorPropertyType":"property","comparatorPropertyValue":"new_state.attributes.ap_mac","comparatorType":"is","comparatorValue":"yy:yy:yy:yy:yy:yy"},{"outputId":"ty0ja2o5qb","messageType":"payload","messageValue":"study","messageValueType":"json","comparatorPropertyType":"property","comparatorPropertyValue":"new_state.attributes.ap_mac","comparatorType":"is","comparatorValue":"xx:xx:xx:xx:xx:xx"}],"outputinitially":false,"state_type":"str","x":270,"y":100,"wires":[[],["3ad64e68.958912"],["438ebcf5.f387ec"],["438ebcf5.f387ec"]]},{"id":"bd7a4d76.aa72c8","type":"api-current-state","z":"a14cb62d.365d4","name":"Livingroom lamp on?","server":"5f01146c.501bec","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"light.ikea_lights_livingroom","state_type":"str","state_location":"","override_payload":"none","entity_location":"","override_data":"none","blockInputOverrides":false,"x":380,"y":460,"wires":[["3af0f039.7ebe48"],[]]},{"id":"ff433ddb.8215a","type":"api-current-state","z":"a14cb62d.365d4","name":"Diningroom lamp on?","server":"5f01146c.501bec","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"light.ikea_lights_diningroom","state_type":"str","state_location":"","override_payload":"none","entity_location":"","override_data":"none","blockInputOverrides":false,"x":380,"y":520,"wires":[["6a3e012c.f55e5"],[]]},{"id":"6a3e012c.f55e5","type":"api-call-service","z":"a14cb62d.365d4","name":"Switch diningroom lamp brightness","server":"5f01146c.501bec","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.ikea_lights_diningroom","data":"{    \"brightness\": {{payload}},    \"transition\": 5}","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":680,"y":520,"wires":[["7117463a.2adef8"]]},{"id":"3af0f039.7ebe48","type":"api-call-service","z":"a14cb62d.365d4","name":"Switch livingroom lamp brightness","server":"5f01146c.501bec","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.ikea_lights_livingroom","data":"{    \"brightness\": {{payload}},    \"transition\": 5}","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":680,"y":460,"wires":[["7117463a.2adef8"]]},{"id":"7117463a.2adef8","type":"debug","z":"a14cb62d.365d4","name":"Lamp output","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":970,"y":480,"wires":[]},{"id":"1ec5cb28.c96d1d","type":"inject","z":"a14cb62d.365d4","name":"Livingroom","topic":"","payload":"{\"entity_id\":\"device_tracker.oneplus6\",\"old_state\":{\"state\":\"home\",\"attributes\":{\"ap_mac\":\"yy:yy:yy:yy:yy:yy\"}},\"new_state\":{\"state\":\"home\",\"attributes\":{\"ap_mac\":\"yy:yy:yy:yy:yy:yy\"}}}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":100,"y":100,"wires":[["3add9afa.c1b24e"]]},{"id":"d6e0a2a9.82b67","type":"inject","z":"a14cb62d.365d4","name":"Study","topic":"","payload":"{\"entity_id\":\"device_tracker.oneplus_5t\",\"old_state\":{\"state\":\"home\",\"attributes\":{\"ap_mac\":\"xx:xx:xx:xx:xx:xx\"}},\"new_state\":{\"state\":\"home\",\"attributes\":{\"ap_mac\":\"xx:xx:xx:xx:xx:xx\"}}}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":260,"wires":[["9fa5639b.a10048"]]},{"id":"5f776fc4.beaf9","type":"inject","z":"a14cb62d.365d4","name":"Livingroom","topic":"","payload":"{\"entity_id\":\"device_tracker.oneplus_5t\",\"old_state\":{\"state\":\"home\",\"attributes\":{\"ap_mac\":\"yy:yy:yy:yy:yy:yy\"}},\"new_state\":{\"state\":\"home\",\"attributes\":{\"ap_mac\":\"yy:yy:yy:yy:yy:yy\"}}}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":100,"y":300,"wires":[["9fa5639b.a10048"]]},{"id":"438ebcf5.f387ec","type":"function","z":"a14cb62d.365d4","name":"Store location","func":"if (msg.topic == \"device_tracker.oneplus_5t\") {\n    flow.set(\"op5t\", msg.payload);\n} else if (msg.topic == \"device_tracker.oneplus6\") {\n    flow.set(\"op6\", msg.payload);\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":500,"y":180,"wires":[["cc7cf062.72b158"]]},{"id":"cc7cf062.72b158","type":"function","z":"a14cb62d.365d4","name":"Determine brightness","func":"var brightness = 1;\nvar max_brightness = 216;\n\nvar dev1 = flow.get('op5t') || '';\nvar dev2 = flow.get('op6') || '';\n\nif (dev1 == \"livingroom\" || dev2 == \"livingroom\") {\n    brightness = max_brightness;\n}\n\nvar newmsg = { payload: brightness };     \nreturn newmsg;","outputs":1,"noerr":0,"x":700,"y":180,"wires":[["bd7a4d76.aa72c8","ff433ddb.8215a","5ffe467b.bc1e1"]]},{"id":"3ad64e68.958912","type":"change","z":"a14cb62d.365d4","name":"Clear OP6 location","rules":[{"t":"delete","p":"op6","pt":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":60,"wires":[[]]},{"id":"74ade5db.400c5c","type":"change","z":"a14cb62d.365d4","name":"Clear OP5T location","rules":[{"t":"delete","p":"op5t","pt":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":260,"wires":[[]]},{"id":"7451b8f8.a5fe78","type":"inject","z":"a14cb62d.365d4","name":"Away","topic":"","payload":"{\"entity_id\":\"device_tracker.oneplus6\",\"old_state\":{\"state\":\"away\",\"attributes\":{\"ap_mac\":\"yy:yy:yy:yy:yy:yy\"}},\"new_state\":{\"state\":\"away\",\"attributes\":{\"ap_mac\":\"yy:yy:yy:yy:yy:yy\"}}}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":140,"wires":[["3add9afa.c1b24e"]]},{"id":"5ea4c433.72dcec","type":"inject","z":"a14cb62d.365d4","name":"Away","topic":"","payload":"{\"entity_id\":\"device_tracker.oneplus_5t\",\"old_state\":{\"state\":\"away\",\"attributes\":{\"ap_mac\":\"yy:yy:yy:yy:yy:yy\"}},\"new_state\":{\"state\":\"away\",\"attributes\":{\"ap_mac\":\"yy:yy:yy:yy:yy:yy\"}}}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":340,"wires":[["9fa5639b.a10048"]]},{"id":"9fa5639b.a10048","type":"trigger-state","z":"a14cb62d.365d4","name":"OP5T Tracker","server":"5f01146c.501bec","entityid":"device_tracker.oneplus_5t","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"id":"m4yph6mr2nm","targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"home"}],"constraintsmustmatch":"all","outputs":4,"customoutputs":[{"outputId":"sikaxqno59","messageType":"payload","messageValue":"livingroom","messageValueType":"json","comparatorPropertyType":"property","comparatorPropertyValue":"new_state.attributes.ap_mac","comparatorType":"is","comparatorValue":"yy:yy:yy:yy:yy:yy"},{"outputId":"ty0ja2o5qb","messageType":"payload","messageValue":"study","messageValueType":"json","comparatorPropertyType":"property","comparatorPropertyValue":"new_state.attributes.ap_mac","comparatorType":"is","comparatorValue":"xx:xx:xx:xx:xx:xx"}],"outputinitially":false,"state_type":"str","x":280,"y":300,"wires":[[],["74ade5db.400c5c"],["438ebcf5.f387ec"],["438ebcf5.f387ec"]]},{"id":"5ffe467b.bc1e1","type":"debug","z":"a14cb62d.365d4","name":"Brightness","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":940,"y":180,"wires":[]},{"id":"5f01146c.501bec","type":"server","z":"","name":"Home Assistant"}]
Bijlagen
unifi-tracker.PNG
Orange Love Trio -- using Ubiquiti USG-3
Orange Dolphin & Proximus (corporate) -- Using OnePlus 6 (ROM: Stock)

Gebruikersavatar
bitbite
Pro Member
Pro Member
Berichten: 439
Lid geworden op: 18 Dec 2012
Bedankt: 34 keer
Recent bedankt: 3 keer
Uitgedeelde bedankjes: 23 keer

Re: HA presence detection, welke AP connected

Berichtdoor bitbite » 02 Feb 2020, 22:47

Hoe debug je eigenlijk de presence detection? 'k Heb hier een setup die schitterend werkt (openwrt en mikrotik), behalve voor mijn eigen gsm (mijn vrouw lukt bvb probleemloos) hoewel die client gewoon in het lijstje staat op de AP's. Eigenlijk weet ik gewoon niet waar te beginnen.

Gebruikersavatar
devilkin
Elite Poster
Elite Poster
Berichten: 2693
Lid geworden op: 17 Mei 2006
Twitter: jdeluyck
Locatie: Gent
Bedankt: 124 keer
Recent bedankt: 24 keer
Uitgedeelde bedankjes: 265 keer
Contact:

Re: HA presence detection, welke AP connected

Berichtdoor devilkin » 02 Feb 2020, 22:54

Trial en error... Disconnect gsm, zie wat het geeft, input injection in node red,...

Sent from my ONEPLUS A6003 using Tapatalk
Orange Love Trio -- using Ubiquiti USG-3
Orange Dolphin & Proximus (corporate) -- Using OnePlus 6 (ROM: Stock)

sky
Premium Member
Premium Member
Berichten: 738
Lid geworden op: 22 Mei 2003
Locatie: Gent
Bedankt: 79 keer
Uitgedeelde bedankjes: 16 keer

Re: HA presence detection, welke AP connected

Berichtdoor sky » 03 Feb 2020, 06:44

devilkin schreef:Ik heb zoiets gebouwd, en dat werkt... maar het is niet echt vriendelijk als je met veel mensen zit die je wilt tracken.

Ik baseer me op de new_state.attributes.ap_mac, en dus het MAC adres van het AP.

Thx. dat werkt idd zoals het hoort.

Bitbite,
Staat je telefoon in de known devices.yaml?

Gebruikersavatar
bitbite
Pro Member
Pro Member
Berichten: 439
Lid geworden op: 18 Dec 2012
Bedankt: 34 keer
Recent bedankt: 3 keer
Uitgedeelde bedankjes: 23 keer

Re: HA presence detection, welke AP connected

Berichtdoor bitbite » 03 Feb 2020, 09:17

Edit Bij mij was de kern van het probleem dus dat de openwrt-luci detectiemethode niet alle devices oppikt. 'k Ben dan overgestapt naar de ubus methode en voorlopig lukt alles.

sky
Premium Member
Premium Member
Berichten: 738
Lid geworden op: 22 Mei 2003
Locatie: Gent
Bedankt: 79 keer
Uitgedeelde bedankjes: 16 keer

Re: HA presence detection, welke AP connected

Berichtdoor sky » 03 Feb 2020, 18:22

devilkin schreef:Ik heb zoiets gebouwd, en dat werkt... maar het is niet echt vriendelijk als je met veel mensen zit die je wilt tracken.

Ik baseer me op de new_state.attributes.ap_mac, en dus het MAC adres van het AP.

[code]

Wat doet diet blocked en allowed uitgang van die trigger?
Op de debugger zie ik daar niets verschijnen.


Terug naar “Home automation en domotica”

Wie is er online

Gebruikers op dit forum: Geen geregistreerde gebruikers en 1 gast