NodeMCU part is done and working, but for the love of GOD, I cannot get HA to recognize the sensor via MQTT. The moment I place below code . I loose complete web access to HASS.IO. All other mqtt devices are working but this. Node MCU is working good as I can see terminal output in ESPlorer. But HA does not show anything when I try to add the mqtt code. The configuration checker says all valid!, but when I restart HA I loose complete access to web interface for hass.io. Unless I remove the below code then all is back nicely. Please assist.
Have you configured it as binary_sensor ?
Your code doesn’t show this.
And please read the blue box on top of every page here how to format codeblocks.
ok yes forgot the binary_sensor, this gave me a small circle at the top of the page, nothing like the tut I followed. see image (https://raw.githubusercontent.com/patrickeasters/smart-house/master/_etc/img/outside.png?v1) Also the icon I get at the top always stays at open, even when I close the reed switch. I however can see “Pin 1 has changed to 1” and “Pin 1 has changed to 0” status in ESPlorer meaning the read switch and nodeMCU are working fine. What else is missing form HA yaml file … thanks for such a prompt reply.
If HA stops working when component added to config files that is normally result of space issue or misplaced quotes. I forget proper spacing but below seems right
If you want your sensors in cards, you have to group them.
Are you sure the NodeMCU publishes to your mqtt broker and the right topic?
Verify this with a mqtt client.
in both the state I see HA correctly displaying open and close door. BUT, via actual Reed switch it still is not working. When I bring the reed switch in close position I can see the message in ESPlorer “Pin 1 has changed to 1” and when I remove the reed switch I see “Pin 1 has changed to 0” BUT the same is not communicated to HA. however if I run manual mqtt command HA responds …
Also sharing my config.lua file
– let’s define the pins
– Map the GPIO pin number to a MQTT topic
map = {}
map[1] = “Front_Door”
map[2] = “Back_Door”
map[5] = “Garage_Entry”
Do you see any messages on the given topics if you use the mosquitto_sub client? mosquitto_sub -h 192.168.1.174 -t "#" -v
If not, there’s something wrong with the lua config.
I don’t see any value for the mqtt broker adress.
core-ssh:~# mosquitto_sub -h 192.168.1.174 -t “#” -v
pat/alarm/Front Door closed
pat/alarm/Back Door closed
pat/alarm/Garage Entry closed
pat/alarm/Front_Door open
pat/alarm/Back_Door open
pat/alarm/Garage_Entry open
I dont understand the first three. And yes even I think something is wrong in the lua config. Let me see if I can re download the original and re edit and re upload. Will report …
ok friend …I got things to work. With a tiny issue still there, First of all for those who might be stuck in the same problem, The issue was with the init.lua, where the command “wifi.sta.config(SSID,PSK,0)” had to be changed to "wifi.sta.config {ssid=“SSID”, pwd=“SSIS paswword”}. After that all worked good.
BUT I have a TINY issue … The state of door on HA is reversed, meaning when I close the reed switch it shows open and vice versa. I thought I need to simply reverse the payload in config.lua file and also reverse the same in yaml file so the changes config became as bwlow …
– let’s define the pins
– Map the GPIO pin number to a MQTT topic
map = {}
map[1] = “Front_Door”
map[2] = “Back_Door”
map[5] = “Garage_Entry”
hehe …ok now I got it … thanks … I made the changes and now all is good… THANKS A TON for staying there and helping me out …people like you are the soul of these communities … …
BTY a last suggestion if you can give. Now I want the notification on my mobile, what the best approach. any notification component from HA should I use or IFTTT is the better approach, Basically whats the best approach to get this done. Thanks again …