Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HA discovery option to PIR sermod #2853

Merged
merged 2 commits into from
Oct 26, 2022
Merged

Add HA discovery option to PIR sermod #2853

merged 2 commits into from
Oct 26, 2022

Conversation

blazoncek
Copy link
Collaborator

Replaces #2724 where I accidentally pushed changes from main branch messing up commit history.

@blazoncek
Copy link
Collaborator Author

@albarlow can you verify this still works as intended as I do not own HA?

@albarlow
Copy link
Contributor

The code is looking right but I'm not getting the message publishing. I deleted out the existing message and then rebuilt the firmware from the pir-ha-discovery channel and it's not published the message. I'll take a further look tomorrow in case its something at my end.

@blazoncek
Copy link
Collaborator Author

blazoncek commented Oct 24, 2022

I moved the initial broadcast into connected() as to not need retained message.
If the message is retained the broadcast can go into setup() instead.

EDIT: It should not be in loop().

@blazoncek
Copy link
Collaborator Author

@albarlow I have it correctly publish (when MQTT broker connection is established) but comparing the topic to other HA autodiscovery topics (in Multi Relay and Temperature usermods) this seems off as it publishes on wled/# global topic instead of homeassistant/#

https://www.home-assistant.io/docs/mqtt/discovery/

@albarlow
Copy link
Contributor

I have tried again this evening and I can confirm that for me this is also working now, my existing entity in home assistant was able to detect this as the same device and has linked it the brightness sensor usermod output so they all appear in the same device (pictured below with BH1750 usermod output).

I like the use of linking it to onMQTTConnect - that feels better than having it on setup. Is that something I can port to the other two usermods I've been working on as I don't recall seeing that as something to harness previously(?)

image

@blazoncek
Copy link
Collaborator Author

Yes, you can. I've added (but not documented) the feature when implementing Multi Relay usermod.

@blazoncek
Copy link
Collaborator Author

I've also had this verified independently by @srg74 and he also confirmed it working. So I'll merge this PR and close the other.

@blazoncek blazoncek merged commit 7211e6b into main Oct 26, 2022
@blazoncek blazoncek deleted the PIR-HA-discovery branch November 4, 2022 22:40
@Sangoku
Copy link

Sangoku commented Nov 7, 2022

Sorry, but this seems to break HA integrations.
I have a fresh installation on esp01s
platform ini overide:

[platformio]
default_envs = WLED_motion

[env:WLED_motion]
board = esp01_1m
upload_speed = 74880
upload_port = COM7
platform = ${common.platform_wled_default}
platform_packages = ${common.platform_packages}
board_build.ldscript = ${common.ldscript_1m128k}
lib_deps = ${esp8266.lib_deps}
build_unflags = ${common.build_unflags}
build_flags = ${common.build_flags_esp8266}
; *********************************************************************
; *** Use custom settings from file my_config.h
  ;  -DWLED_USE_MY_CONFIG
; *********************************************************************das
;
;
; *** To use the below defines/overrides, copy and paste each onto it's own line just below build_flags in the section above.
; 
; disable specific features
;  -D WLED_DISABLE_OTA
 -D WLED_DISABLE_ALEXA
 -D WLED_DISABLE_BLYNK
 -D WLED_DISABLE_HUESYNC
 -D WLED_DISABLE_INFRARED
;  -D WLED_DISABLE_WEBSOCKETS
; PIN defines - uncomment and change, if needed:
  -D LEDPIN=2
;   -D BTNPIN=0
;   -D TOUCHPIN=T0
;   -D IRPIN=4
;   -D RLYPIN=12
;   -D RLYMDE=1
; digital LED strip types - uncomment only one ! - this will disable WS281x / SK681x support
;   -D USE_APA102
  ; -D USE_WS2801
;   -D USE_LPD8806
; PIN defines for 2 wire LEDs
   ; -D CLKPIN=0
   ; -D DATAPIN=2
; to drive analog LED strips (aka 5050) hardware configuration is no longer necessary
; configure the settings in the UI as follows (hard):
;   for the Magic Home LED Controller use PWM pins 5,12,13,15
;   for the H801 controller use PINs 15,13,12,14 (W2 = 04)
;   for the BW-LT11 controller use PINs 12,4,14,5
;   
; set the name of the module - make sure there is a quote-backslash-quote before the name and a backslash-quote-quote after the name
  -D SERVERNAME="\"WLED-Bathrom\""

; enable PIR usermod
  -D USERMOD_PIRSWITCH
  -D PIR_SENSOR_PIN=0

; wifi sid:
  -D CLIENT_SSID="\"111\""
  -D CLIENT_PASS="\"2222!!!\""

Something is broken... im cant get the entry to show up.

MQTT does not publish the motion topic to.. no matter what i try.

@blazoncek
Copy link
Collaborator Author

Please use a pre-compiled binaries from @srg74 and report back.

@Sangoku
Copy link

Sangoku commented Nov 8, 2022

Please use a pre-compiled binaries from @srg74 and report back.

as far i see he has only esp32 this is a esp01s. Or am i missing it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants