[Monitor] Reliable, Multi-User, Distributed BT Occupancy/Presence Detection

mqtt
automation
Tags: #<Tag:0x00007f47faece548> #<Tag:0x00007f47faece368>

#407

mark do you have teamview installed on your computer?? maybe I can remote in and help you out. Im in the EST time zone


#408

I installed monitor and it seems to be working correctly. I have three phones that I am monitoring for and I see monitor send mqtt messages about all three of them. However, only 1 phone shows up in Home Assistant with a percentage of confidence. The other 2 just show a dash in the icon.Confidence%20Badges

Here is my yaml in home assistant:

  - platform: mqtt
    state_topic: 'monitor/CONTROLLER-02/a8:5b:78:xx:xx:xx'
    value_template: '{{ value_json.confidence }}'
    unit_of_measurement: '%'
    name: 'Greg Controller-02'

  - platform: mqtt
    state_topic: 'monitor/CONTROLLER-02/b4:4b:d2:xx:xx:xx'
    value_template: '{{ value_json.confidence }}'
    unit_of_measurement: '%'
    name: 'Steph Controller-02'

  - platform: mqtt
    state_topic: 'monitor/CONTROLLER-02/b4:4b:d2:xx:xx:xx'
    value_template: '{{ value_json.confidence }}'
    unit_of_measurement: '%'
    name: 'Gabe Controller-02'

all of that is under -sensor:

Am I doing something wrong?


#409

Are the Mac’s for Steph and Gabe diffrerent?? I assume so they just look really close together.

You need to view the messages being sent to the MQTT server to see what actually happenning.

Do a
journalctl -f -u monitor.service

and you should be able to see what the messages look like going to the MQTT server.
This should tell you if its the HASS config or the Monitor config


#410

The MACs are different.

Here is what I am seeing from the MQTT server when I subscribe to monitor/#

{“id”:“a8:5b:78:38:2c:4e”, “retained”:“false”, “version”:“0.1.675”, “confidence”:“0”,“name”:“Greg_Phone “,“timestamp”:“Thu Nov 01 2018 14:16:27 GMT-0500 (CDT)”,“manufacturer”:“Apple, Inc.”,“type”:“KNOWN_MAC”,“rssi”:””}

{“id”:“b4:4b:d2:xx:xx:x1”, “retained”:“false”, “version”:“0.1.675”, “confidence”:“0”,“name”:“Steph_Phone “,“timestamp”:“Thu Nov 01 2018 14:16:36 GMT-0500 (CDT)”,“manufacturer”:“Apple, Inc.
Apple, Inc.”,“type”:“KNOWN_MAC”,“rssi”:””}

{“id”:“b4:4b:d2:xx:xx:x2”, “retained”:“false”, “version”:“0.1.675”, “confidence”:“0”,“name”:“Gabe_Phone “,“timestamp”:“Thu Nov 01 2018 14:16:44 GMT-0500 (CDT)”,“manufacturer”:“Apple, Inc.
Apple, Inc.”,“type”:“KNOWN_MAC”,“rssi”:””}


#411

Can you see what topics its giving? Are they matching the sensor topics?


#412

Try this config to see if any information is coming through

- platform: mqtt
  state_topic: 'monitor/CONTROLLER-02/a8:5b:78:xx:xx:xx'
  value_template: '{{ value_json.confidence }}'
  unit_of_measurement: '%'
  name: 'Greg Controller-02'
  availability_topic: 'monitor/CONTROLLER-02/status'
  payload_available: "online"
  payload_not_available: "offline"
  json_attributes:
    - id
    - name 
    - rssi
    - version
    - manufacturer
    - type
    - timestamp
    - retained
    - confidence

- platform: mqtt
  state_topic: 'monitor/CONTROLLER-02/b4:4b:d2:xx:xx:xx'
  value_template: '{{ value_json.confidence }}'
  unit_of_measurement: '%'
  name: 'Steph Controller-02'
  availability_topic: 'monitor/CONTROLLER-02/status'
  payload_available: "online"
  payload_not_available: "offline"
  json_attributes:
    - id
    - name 
    - rssi
    - version
    - manufacturer
    - type
    - timestamp
    - retained
    - confidence

- platform: mqtt
  state_topic: 'monitor/CONTROLLER-02/b4:4b:d2:xx:xx:xx'
  value_template: '{{ value_json.confidence }}'
  unit_of_measurement: '%'
  name: 'Gabe Controller-02'
  availability_topic: 'monitor/CONTROLLER-02/status'
  payload_available: "online"
  payload_not_available: "offline"
  json_attributes:
    - id
    - name 
    - rssi
    - version
    - manufacturer
    - type
    - timestamp
    - retained
    - confidence

#413

The topics are:
monitor/CONTROLLER-02/a8:5b:78:xx:xx:xx
monitor/CONTROLLER-02/b4:4b:d2:xx:xx:x1
monitor/CONTROLLER-02/b4:4b:d2:xx:xx:x2

they match what is in my ha config file

I’m restarting HA now with the changes you suggested


#414

Now only two show up and they both say unavailable:
Unavailable

Here is what i pasted:

-sensor:
  - platform: mqtt
    state_topic: 'monitor/CONTROLLER-02/a8:5b:78:xx:xx:xx'
    value_template: '{{ value_json.confidence }}'
    unit_of_measurement: '%'
    name: 'Greg Controller-02'
    availability_topic: 'monitor/CONTROLLER-02/status'
    payload_available: "online"
    payload_not_available: "offline"
    json_attributes:
      - id
      - name 
      - rssi
      - version
      - manufacturer
      - type
      - timestamp
      - retained
      - confidence

  - platform: mqtt
    state_topic: 'monitor/CONTROLLER-02/b4:4b:d2:xx:xx:x1'
    value_template: '{{ value_json.confidence }}'
    unit_of_measurement: '%'
    name: 'Steph Controller-02'
    availability_topic: 'monitor/CONTROLLER-02/status'
    payload_available: "online"
    payload_not_available: "offline"
    json_attributes:
      - id
      - name 
      - rssi
      - version
      - manufacturer
      - type
      - timestamp
      - retained
      - confidence

  - platform: mqtt
    state_topic: 'monitor/CONTROLLER-02/b4:4b:d2:xx:xx:x2'
    value_template: '{{ value_json.confidence }}'
    unit_of_measurement: '%'
    name: 'Steph Controller-02'
    availability_topic: 'monitor/CONTROLLER-02/status'
    payload_available: "online"
    payload_not_available: "offline"
    json_attributes:
      - id
      - name 
      - rssi
      - version
      - manufacturer
      - type
      - timestamp
      - retained
      - confidence

#415

do you have the dash in front of Sensor like you have it in the config? if so take the dash out.

Also do you mind adding the -x to the monitor instance so it retains the messages to the mqtt


#416

I copied and pasted something funny. That is why Gabe’s phone didn’t show up. I fixed my bad pasting job and then I restarted monitor. Now I see all three again but only the one is showing anything:

Not sure what to make of this.


#417

I did not have the - in front of sensor:

I just stopped the service and ran sudo bash monitor.sh -x

Now I am seeing retained : true in the messages going to my MQTT server


#418

but im assuming you are still not seeing anything different with the other 2 sensors?


#419

Correct. I am still seeing the same issue with the other 2 sensors


#420

What model iPhone’s are they ? I had an iphone 5 that no matter what I did, I couldn’t get it to be recognised.


#421

The one that is showing up is an iPhone 6s, the 2 that aren’t showing up are iPhone 5s.

The weird thing is that I see the messages from all 3 phones being passed to the MQTT server, but only the one is being reported in HA.

I even tried changing the order of how I had them configured in HA, but I get the same result.


#422

I do thanks, but I am GMT. Just a question thought please.
If I install this and want it to trigger on depart (which works well) and trigger on arrival, what switches do you use and want are your settings in behavior_preferences please?


#423

As i said, it was a 5 that I had a problem with, I didn’t have a loads of time to mess around with it, as it was only a friends phone that was here for a few days, but tried pairing it with a speaker, which is what seemed to cure a lot of people’s problem’s, but didn’t work for me on this device.

Don’t know if anyone else here is a using an iPhone 5s with Monitor that can just confirm they do actually work ok,


#424

Can you try them one at a time to see if they can connected individually?


#425
monitor.sh -tadr 

-tadr is going to do arrival scans ONLY on trigger.

You could always do
monitor.sh -tdr

And still send arrival triggers. It will still trigger arrivals AND you can have it also triggering on random advertisements

My behavior preferences are basically the stock values except I do less depart tries. If you want stock do a -d
What are you planning on using to trigger arrivals?


#426

cheers for this. this is my problem, arrivals I don’t know what I should use, as I thought the phone would do BT adverts and be detected by monitor on the Pi Zero.
I want it to have porch lights on as we arrive etc.

I currently use iBeacons and OwnTracks but iBeacons are being stopped and OT is starting to be a bit flaky, hence I thought this was the solution :slight_smile: