Closed koensayr closed 4 years ago
Below is short snip of the mqtt-broker service output
Current Working Directory is /usr/local/lib/node_modules/mqtt-bridge-smartthings 2020-04-23 00:15:30 AM info: Starting SmartThings MQTT Bridge - v1.0.4 2020-04-23 00:15:30 AM info: Configuration Directory - /usr/local/etc 2020-04-23 00:15:30 AM info: Loading configuration 2020-04-23 00:15:31 AM info: Loading previous state 2020-04-23 00:15:31 AM info: Last Request from ST - {} 2020-04-23 00:15:31 AM info: ===================================ACTUAL SUBSCRIPTIONS REQUESTED FROM SMARTAPP ============================================ 2020-04-23 00:15:31 AM info: Currently subscribed to 2020-04-23 00:15:31 AM info: ============================================================================================================================ 2020-04-23 00:15:31 AM info: Saving current state 2020-04-23 00:15:31 AM info: Connecting to MQTT at mqtt://localhost 2020-04-23 00:15:31 AM info: Configuring autosave 2020-04-23 00:15:31 AM info: Configuring API 2020-04-23 00:15:31 AM info: Listening at http://localhost:4040
Updated now with a devices.yaml file
2020-04-23 00:24:55 AM debug: Subscription smartthings/stat/lifx1/POWER [Master Bath],[switch],[{ OFF: 'off', ON: 'on' }] 2020-04-23 00:24:55 AM debug: Subscription: smartthings/stat/lifx1/POWER - Device { 'Master Bath': [Object] } 2020-04-23 00:24:55 AM info: ============================ALL POSSIBLE SUBSCRIPTIONS FROM ALL EXTERNAL DEVICES =========================================== 2020-04-23 00:24:55 AM info: Subscription smartthings/stat/lifx1/POWER [Master Bath],[switch],[{"OFF":"off","ON":"on"}] 2020-04-23 00:24:55 AM info: ============================================================================================================================
Have you double checked the logs in the graph IDE? I was having some similar trouble, turns out the smartapp wasn't working at all (was getting no logs in the graph IDE), and just re-saving it kicked things back into gear (and messages started pouring back into the bridge and then into my MQTT and finally into HA again).
Interesting. I've seen some flakiness with web IDE. It does look like I'm getting events when I toggle lights on and off from the Smartthings iOS app, but I still get no love in the logs
Perhaps this is a hint?
I actually switched back to stj after having some config issues with gupta, but my logs don’t look like that, are you sure those are logs for the bridge app?
Those are all the logs there. @nivekmai when you run the bridge and its working do you see messages on STDOUT?
From the log messages above, it looks like the SmartApp is attempting to deliver the messages?
I actually switched back to stj after having some config issues with gupta, but my logs don’t look like that, are you sure those are logs for the bridge app?
could you tell me what config issues were you having? previous users using stj had successfully tested with this implementation.
koensayr
please post devices.yml and log from startup on mbs-server side - might give a clue as to what is happening. not enough info to figure out exactly what is happening
from ST IDE live logging please select the bridge device and msbs-smartapp separately and if possible post those logs - might give better clues
could you tell me what config issues were you having? previous users using stj had successfully tested with this implementation.
I run smartthings-mqtt-bridge using pm2 and keeping the config in my config directory:
pm2 start -n st --cwd /home/homeassistant/.homeassistant/ smartthings-mqtt-bridge
mqtt-bridge-smartthings seemed to be ignoring the cwd, and was trying to reach a directory that doesn't exist:
Error: ENOENT: no such file or directory, open '/home/pi/.nvm/versions/node/v14.0.0/lib/node_modules/mqtt-bridge-smartthings/config/_config.yml'
at Object.openSync (fs.js:461:3)
at Object.readFileSync (fs.js:364:35)
at loadConfiguration (/home/pi/.nvm/versions/node/v14.0.0/lib/node_modules/mqtt-bridge-smartthings/mbs-server.js:118:36)
at Object.<anonymous> (/home/pi/.nvm/versions/node/v14.0.0/lib/node_modules/mqtt-bridge-smartthings/mbs-server.js:65:11)
at Module._compile (internal/modules/cjs/loader.js:1185:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1205:10)
at Module.load (internal/modules/cjs/loader.js:1034:32)
at Function.Module._load (internal/modules/cjs/loader.js:923:14)
at Module.require (internal/modules/cjs/loader.js:1074:19)
at Module.Hook._require.Module.require (/usr/local/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:70:39) {
errno: -2,
syscall: 'open',
code: 'ENOENT',
path: '/home/pi/.nvm/versions/node/v14.0.0/lib/node_modules/mqtt-bridge-smartthings/config/_config.yml'
}
When I checked, /home/pi/.nvm/versions/node/v14.0.0/lib/node_modules/mqtt-bridge-smartthings/_config.yml
existed, and /home/pi/.nvm/versions/node/v14.0.0/lib/node_modules/mqtt-bridge-smartthings/config
did not.
I don't need to send messages back to smartthings (it's simply acting as a zigbee bridge for me), so I just switched back to stj 'cause I knew it worked.
yeah for the new version i created a config directory that will also contain data and log directories to store state information and log files - thats part of the major rehaul of the framework.
FROM the REadme
you can specify a CONFIG_DIR environment variable to specify where the config directory or it will default to locating the config directory in the same folder where mbs-server. This is a change form vesions 1.02 and earlier where config files were not in a separate sub-directory
if you just create a config directory and put the config file there i think you would be set
@sgupta999 I'll post you more consolidated logs a bit later tonight. I really appreciate your attention to this. I'll buy you lunch next time we can leave the house.
FWIW I did post the mqtt-broker logs above
Huh, well I have no idea what changed. But perhaps it is working. I suppose I did try the configuration tonight WITHOUT a devices.yaml file. I don't have a good way to give you logs from the IDE other then screenshots so I've attached them
Here are the logs from mqtt-broker:
plex:etc plex$ export CONFIG_DIR=/usr/local/etc plex:etc plex$ mqtt-bridge-smartthings Current Working Directory is /usr/local/lib/node_modules/mqtt-bridge-smartthings 2020-04-23 23:39:34 PM info: Starting SmartThings MQTT Bridge - v1.0.4 2020-04-23 23:39:34 PM info: Configuration Directory - /usr/local/etc 2020-04-23 23:39:34 PM info: Loading configuration 2020-04-23 23:39:34 PM info: Loading previous state 2020-04-23 23:39:34 PM info: Last Request from ST - {} 2020-04-23 23:39:34 PM info: ===================================ACTUAL SUBSCRIPTIONS REQUESTED FROM SMARTAPP ============================================ 2020-04-23 23:39:34 PM info: Currently subscribed to 2020-04-23 23:39:34 PM info: ============================================================================================================================ 2020-04-23 23:39:34 PM info: Saving current state 2020-04-23 23:39:34 PM info: Connecting to MQTT at mqtt://localhost 2020-04-23 23:39:34 PM info: Configuring autosave 2020-04-23 23:39:34 PM info: Configuring API 2020-04-23 23:39:34 PM info: Listening at http://localhost:4040 2020-04-23 23:41:08 PM debug: From ST: - switch - off 2020-04-23 23:41:08 PM debug: Device from SmartThings: smartthings/Master Bath/switch = off 2020-04-23 23:41:08 PM info: ST --> MQTT: [Master Bath][switch][off] [smartthings/Master Bath/switch][off] 2020-04-23 23:41:13 PM debug: From ST: - switch - on 2020-04-23 23:41:13 PM debug: Device from SmartThings: smartthings/Master Bath/switch = on 2020-04-23 23:41:13 PM info: ST --> MQTT: [Master Bath][switch][on] [smartthings/Master Bath/switch][on]
@sgupta999 Perhaps you can share if I need a devices.yml in this case?
Now to tie this into Indigo Domo (indigodomo.com)
It seems that my LIFX devices are working, but I've created a "Virtual Switch" in the ST IDE. It shows up in the app on my iPhone, but toggling it on/off doesn't generate any MQTT traffic
Forgot. Just I guess had to subscribe to it in the iOS App
Now I'm seeing a POSSIBLE LOOP Message
2020-04-23 23:55:13 PM debug: From ST: - switch - on 2020-04-23 23:55:13 PM debug: Device from SmartThings: smartthings/Virtual Test Switch/switch = on 2020-04-23 23:55:13 PM info: ST --> MQTT: [Virtual Test Switch][switch][on] [smartthings/Virtual Test Switch/switch][on] 2020-04-23 23:55:13 PM warn: POSSIBLE LOOP. Device[Attribute] Virtual Test Switch[switch] is publishing to Topic smartthings/Virtual Test Switch/switch while subscribed to Topic [ 'smartthings/Virtual Test Switch/switch' ] 2020-04-23 23:55:13 PM debug: From MQTT: smartthings/Virtual Test Switch/switch = on 2020-04-23 23:55:13 PM info: Skipping duplicate message from: smartthings/Virtual Test Switch/switch = on
so "POSSIBLE LOOP" is a warning that i issue where you are subscribed to the same topic you are publishing to.
If your not using the devices,yml then your publishing and subscription topics should be different as you are using legacy implementation. the legacy implementation is only for hass io from what I can tell not sure how it works with LIFX - i have tried to not modify it and just retain it.
I would suggest try to use devices.yml if possible.
the POSSIBLE LOOP is just a warning - ST has checks built in, and i build some checks (i.e. only if you are using devices.yml) to eliminate looping. That said if you are not actually seeing looping behavior you should be okay.
Since things seems to be working for me now (I'm not sure what changed) I'm going to ahead and close this. Thank you @sgupta999 for your help. I really do appreciate it.
So, I'm still excited to see you are working on this, but I'm stuck at the same spot I was with St. Johns Configuration.
I'm expecting that once I see something setup, I should see MQTT messages at the broker when I turn on and off devices that the MQTT Broker is Subscribed to.
In my case, the device I've subscribed to is a LIFX light strip. I'm running the mutt-broker in the foreground and when I toggle the LIFX light in the SmartThings iOS on and off, I can observe the light coming on and off but I don't see messages, or any real output from the broker (running debit fwiw)
What am I missing here? Any help would be appreciated.