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

automation
mqtt
Tags: #<Tag:0x00007f2041977a80> #<Tag:0x00007f20419778f0>

#892

No gives error

.

  GN

=. [x1
  GNU nano 2.7.4       File: mqtt_preferences

# ---------------------------
#                                                             $
# MOSQUITTO PREFERENCES
#                                                             $
# ---------------------------

# IP ADDRESS OR HOSTNAME OF MQTT BROKER
mqtt_address=192.168.1.16

# MQTT BROKER USERNAME (OR BLANK FOR NONE)
mqtt_user=''
# MQTT BROKER PASSWORD (OR BLANK FOR NONE)
mqtt_password=''

# MQTT PUBLISH TOPIC ROOT
mqtt_topicpath=monitor

# PUBLISHER IDENTITY
mqtt_publisher_identity='office_pi3'

# MQTT PORT
mqtt_port='1883'

# MQTT CERTIFICATE FILE (LEAVE BLANK IF NONE)
mqtt_certificate_path=''

#MQTT VERSION (LEAVE BLANK FOR DEFAULT; EXAMPLE: 'mqttv311')
mqtt_version=''


                       [ Read 30 lines ]
^G Get Help ^O Write Out^W Where Is ^K Cut Text ^J Justify
^X Exit     ^R Read File^\ Replace  ^U Uncut Tex^T To Spell

#893

That’s on my hassio mosquitto log (it doesn’t stop until I stop the script)

92.168.1.238 on port 1883. 1549865767: Socket error on client <unknown>, disconnecting. 1549865767: New connection from 192.168.1.238 on port 1883. 1549865767: Socket error on client <unknown>, disconnecting. 1549865768: New connection from 192.168.1.238 on port 1883. 1549865768: Socket error on client


#894

On the device you are running monitor on, try running mosquitto_sub or mosquitto_pub and see if it will connect to your broker.


#895

Ok, but 192.168.1.238 is where monitor is running

 New connection from 192.168.1.238 on port 1883

#896

How you do that?

p.s.
please note that 192.168.1.238 is where monitor is running

 New connection from 192.168.1.238 on port 1883 #mosquitto log (host 192.168.1.16

#897

Google will help with mosquitto_sub or _pub.


#898
[07:58:16] [email protected]:~$ mosquitto_pub -h 192.168.1.16 -t red -m "blue"
[07:59:11] [email protected]:~$ mosquitto_sub -h 192.168.1.16 -t red

pub gives error sub works

1549871929: New client connected from 192.168.1.238 as mosqpub/24513-openHABia (c1, k60).
1549871929: ACL denying access to client with dangerous client id "mosqpub/24513-openHABia"
1549871929: Client mosqpub/24513-openHABia disconnected.
1549871962: New connection from 192.168.1.238 on port 1883.
1549871962: New client connected from 192.168.1.238 as mosqsub/24713-openHABia (c1, k60).

#899

When running the script I do not get the error of ACL denying, but a more simple

1549872148: New connection from 192.168.1.238 on port 1883. 1549872148: Socket error on client &lt;unknown&gt;, disconnecting.

#900

I have seen this client id problem a few times on the forums lately. Try setting

mqtt_publisher_identity=''

to something (anything). In the motion setup I mean.


#901

Its already there. Pluis in my HASSIO mosquitto configuration there is no configuration directory, no ACL

# PUBLISHER IDENTITY
mqtt_publisher_identity='office_pi3'

#902

Ok, I am creating a file in /share/mosquitto/accesscontrollist as written here

http://www.steves-internet-guide.com/topic-restriction-mosquitto-configuration/

but not sure what to write in it

ps
but is strange a lot of devisec (sonoff, and so on) are connecting to the same mosquitto server without any problem.

Also the error (ACL denying access) is given only if I use mosquitto_sub not when I ran the script, so I am not sure its the same thing


#903

Also this is my mosquitto configuration (active is false)

{
  "logins": [
    {
      "username": "",
      "password": ""
    }
  ],
  "anonymous": true,
  "customize": {
    "active": false,
    "folder": "mosquitto"
  },
  "certfile": "fullchain.pem",
  "keyfile": "privkey.pem"
}

EDIT
Ok I changed to port 1884 (from 1883) and its working … but I have both port in the mosquitto hassio ocnfiguration, and other devices all connect to 1883 … strange

p.s. do you also receive the message “Error: success” in monitor log? Means no error, correct?

EDIT, EDIT, the script crashes my HASS instance, could not find anything in the log … have to investigate further (when stopping the script no more crashes)


#904

SO i dont use node red…But this IDEA could help you. (Curious to know how your automations are setup)

This is how my current scripts are running

I only trigger departs when my door closes. WHen my door opens it triggers a cancel of the depart script just incase I have multiple door openings in a small amount of time.

the depart goes

  • send depart scan
  • wait 20 seconds
  • send depart scan
  • wait 40 seconds
  • send depart scan
  • wait 60 seconds
  • Check status of both sensors in my house
  • if mismatched send a restart command and wait 30 seconds
  • If not mismatched check if sensor is 100 or 0 and turn off / on certain automations based on these numbers

The only downside would be if I wanted an arrival automation to happen quickly after depart. In this setup it would take about 2-3 minutes for my arrival automations to turn back on. Let me know if something is unclear


#905

Thank you…
So for my setup its like this

  • When i open the door = nothing
  • When i close the door, it checks our singal and if 100 for both of us = it will run a depart scan
  • If the scan was already running, it will cancel that, wait 15 sec and run again
  • Issue i have is if lets say someone is at 100 inside and i go outside, it will rrun both scripts - arrive and depart and will depart me because i am outside. Now lets say i go into the garage and since the arrival is running because the 2nd person was 100 - it will get me again and bring me home.

I want a check in place where if it departs me; dont bring me back home for lets say 3 mins as i dont want it to bonce around.


#906

@andrewjfreyer

The code snippets I sent before were from running via command line as I was tinkering a lot on the weekend getting the setup just correct.

None the less, ive just stopped it and run via command line, and im not getting the messages anymore. Very strange…

Thank you for investigating anyway and thank you for a great script.


#907

my theory was that you had a latent older version running in the background - glad to hear that things are working well now!


#908

I would create your automations per person and just set a timer after the door closes for 3 min (cancel timer when door opens). After 3 min if user A is 100 turn on depart automations (not running them just making sure they are on)

if user A is 0 after 3 min turn on the Arrival automations (no executiion , just making sure the automation is on)

I would send you a node red config but I dont use nodeRed and have very little desire to learn it at this time. you could check my scripts in my github. (most that I speak of here are toward the bottom)


#909


#910

I have attached a picture of my node red. I have a timer in place in case I am waiting in the car on the driveway already departed at 0 and person B who is at 100 opens the front front door and come out. Now since person B was 100 and I was at 0. Both depart and arrive will run. And there is a chance it may bring me back in if I am withing range slightly. Not sure about the logic but I want it so if my status just changed from home to away, don’t look at me for 3 mins.


#911

OHHHHH I completely missed the part where you are using -TAD
I personally use -TRD

do you have a Camera or Motion sensor that you could use for a arrival trigger instead of the doors? Possibly a fence ? do both users enter/exit from either door?