Closed Gis70 closed 3 years ago
The default topic prefix is home/unifi
and you should see some logging saying as much. I'm using compose; you should certainly see some logging.
unifi2mqtt_1 | [20:12:59] info: TwoMQTT.Managers.MQTTManager[0]
unifi2mqtt_1 | Broker: mosquitto.local
unifi2mqtt_1 | TopicPrefix: home/unifi
unifi2mqtt_1 | DiscoveryEnabled: True
unifi2mqtt_1 | DiscoveryPrefix: homeassistant
unifi2mqtt_1 | DiscoveryName: unifi
...
unifi2mqtt_1 | [20:13:00] info: TwoMQTT.Managers.MQTTManager[0]
unifi2mqtt_1 | Publishing 'ON' on 'home/unifi/mannkind/state'
It's standard dotnet logging, so namespace-based environment variables will enable a lot more spammy logs :)
Example: LOGGING__LOGLEVEL__UNIFI="Debug"
My apologies for the delay, I need to figure out why I wasn't notified of this issue.
Thx for your answer, i will retry with your version instead of dersimn/unifi2mqtt
@mannkind sorry but i'm not able to see something published, that why i was going on another unfi2mqtt. I deploy the docker with docker compose :
No more log with your tips and i don't see any information
version: '3'
services:
unifi2mqtt:
container_name: unifi2mqtt_mannkind
image: mannkind/unifi2mqtt:latest
restart: always
environment:
UNIFI__HOST: "https://192.168.0.65:8443"
UNIFIUSERNAME: "mysusername"
UNIFIPASSWORD: "mypassword"
UNIFIAWAYTIMEOUT: "0.00:05:05"
UNIFIPOLLINGINTERVAL: "0.00:00:12"
UNIFIDISABLESSLVALIDATION: 'true'
UNIFIMQTTTOPICPREFIX: "unifi"
UNIFIMQTTDISCOVERYENABLED: 'false'
UNIFIMQTTDISCOVERYPREFIX: ""
UNIFIMQTTDISCOVERYNAME: "unifi"
UNIFIMQTTBROKER: "mqtt://192.168.0.71"
UNIFIMQTTUSERNAME: "myusername"
UNIFIMQTTPASSWORD: "mypassword"
LOGGINGLOGLEVEL__UNIFI: "debug"`
Hmmm. If you're not seeing logs then something else is going on. What are you trying to run it on? What does Docker output?
It should output something to the console without any envs whatsoever (example below, first run ever).
➜ ~ docker run mannkind/unifi2mqtt:latest
Unable to find image 'mannkind/unifi2mqtt:latest' locally
latest: Pulling from mannkind/unifi2mqtt
f7ec5a41d630: Already exists
dbcaaf8b5596: Already exists
9b8013b17b7e: Already exists
d8d50a433506: Already exists
e47c47f6e188: Pull complete
Digest: sha256:fca467fbc27974cc579c055020fb26fc6fcb29e16498ff146d1b60903d3137a6
Status: Downloaded newer image for mannkind/unifi2mqtt:latest
[22:16:52] info: Unifi.Liasons.SourceLiason[0]
Host: https://unifi.local:8443
Username: unifi
Password: <REDACTED>
Site: default
AwayTimeout: 00:05:01
PollingInterval: 00:00:11
Resources:
[22:16:52] info: TwoMQTT.Managers.MQTTManager[0]
Broker: test.mosquitto.org
Username:
Password:
TopicPrefix: home/unifi
DiscoveryEnabled: True
DiscoveryPrefix: homeassistant
DiscoveryName: unifi
[22:16:52] info: TwoMQTT.Managers.SourceManager[0]
Awaiting incoming commands
[22:16:52] info: TwoMQTT.Managers.SourceManager[0]
Polling source
[22:16:52] info: TwoMQTT.Managers.MQTTManager[0]
Awaiting incoming data
[22:16:52] info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
[22:16:52] info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Production
[22:16:52] info: Microsoft.Hosting.Lifetime[0]
Content root path: /app/
Yes I'm seeing the same thing. Sorry it wasn't clear. I think the problem is to connect to unifi either the broker. That's why I would have more log to see where is the problem because even if i answer all good (in my mind) I have no publish other than the first debug as you shown.
Another strange things is i have to put ' ' instead of '' '' for certain env vars.
Ah, yeah, that wasn't clear at all. Without seeing the logging output you're getting, I can only guess...
A few things to note:
UNIFI__RESOURCES__0__MACAddress: 11:22:33:44:55:66
UNIFI__RESOURCES__0__Slug: myPhone
UNIFI__RESOURCES__1__MACAddress: 81:42:53:14:95:46
UNIFI__RESOURCES__1__Slug: anotherThing
You would see something like the following in the logs.
info: Unifi.Liasons.SourceLiason[0]
... [snip some other values] ...
Resources: SlugMapping { MACAddress = 11:22:33:44:55:66, Slug = myPhone }, SlugMapping { MACAddress = 81:42:53:14:95:46, Slug = anotherThing }
UNIFI__MQTT__DISCOVERYENABLED=FaLSe
Ok, with RESOURCES i have more things
But this is my config, i think there is a problem with UNIFI__MQTT__TOPICPREFIX: "unifi"
because it is not taking into account.
It's publish allways to home/unfi
Same for HA flag, i set it up to false and sometimes it is appearing true. Strange, if not always the same behaviour
Connection to Unifi API seems to be OK
But I see the number of devices varying from 25 to 24 if i put my phone in flight mode but i always seeing publishing OFF for this device.
Well boo. I'm really not sure what's going on with not finding the phone; that's very odd. You're sure the mac address is correct?
I've published a new build here that adds a little more debugging to the SourceDAO. The line should look like {macAddress} found in controller: {found}; last seen at {dt}; presence: {state}
. Should help determine if it's finding it in device list from the controller and the last seen timestamp.
Device connected/found example:
[17:21:40] dbug: Unifi.DataAccess.SourceDAO[0]
Caching 34 clients
[17:21:40] dbug: Unifi.DataAccess.SourceDAO[0]
11:22:33:44:55:66 found in controller: False; last seen at 01/01/0001 00:00:00; presence: False
[17:21:40] dbug: Unifi.Liasons.MQTTLiason[0]
Found slug myPhone for incoming data for 11:22:33:44:55:66
[17:21:40] info: TwoMQTT.Managers.MQTTManager[0]
Publishing 'OFF' on 'testing/myphone/state'
Connected/found example:
[17:22:13] dbug: Unifi.DataAccess.SourceDAO[0]
Caching 34 clients
[17:22:13] dbug: Unifi.DataAccess.SourceDAO[0]
11:22:33:44:55:66 found in controller: True; last seen at 05/01/2021 17:24:13; presence: True
[17:22:13] dbug: Unifi.Liasons.MQTTLiason[0]
Found slug myphone for incoming data for 11:22:33:44:55:66
[17:22:13] info: TwoMQTT.Managers.MQTTManager[0]
Publishing 'ON' on 'testing/myphone/state'
Ok, i found the problem, it's case sensitive aa:bb:cc works but not AA:BB:CC
Thx a lot for your debug level added.
On the main page the link are old
Great! I'll think about adjusting that to be case-insensitive. I've always used whatever the unifi controller displays/returns, so I guess I've not run into it.
Those links are old on purpose. They're old/prior implementations written in a completely different language (Go vs C#) -- in case someone wants to fork/enhance/whatever those prior implementations.
So now it's OK to catch the presence on UNIFI, i have to fix the problem with the broker because nothing is published at the moment. Can you add log for connection to broker ?
It's fine, i added mqtt:// behind the ip adresse, and i musnt's. Thx dud !
See you
Awesome.
I just noticed that "mqtt://" as well and thought it might be an issue. Good to know.
In any event, in the next couple days/week I'll try to figure out how get logging from the manager mqtt client lib I'm using -- it's not using the standard dotnet core logging to my knowledge.
Hello, please can you add some debugs information for connecting to broker and unifi controller, maybe also a trace when a topic is submitted with an environnement variable ?
I don't see any topics, i'm trying to put it in a docker via docker-compose but nothing appears. Some debug line would be appreciated :-)
Thx