I have a LEDVANCE Classic A 60 bulb connected to a traditional light switch. The integration with HASS is through the zigbee2mqtt interface. Everything is working as expected. I now would like to get a message when somebody turned the traditional light switch to off, so that the HASS commands cannot work anymore (No communication to HASS due to missing power on the bulb). Somewhere I have read, that it can be done through testing the state for ‘unavailable/available’. But I only can test states only for brightness,… etc, but not for available or unavailable.
How can this testing be done?
Thanks for any advice.
Use the State trigger option, not the device trigger. There you can specify whatever you want, which in your case will be unavailable
- if it’s available then it’ll either be on
or off
.
Thank you for responding. I have tried this:
- id: '1650729990827'
alias: Buero Sued Ein
description: ''
trigger:
- platform: time_pattern
seconds: /20
condition:
- condition: state
entity_id: light.mqtt_json_light_6
state: unavailable
action:
- service: notify.mobile_app_iphone_von_kurt
data:
message: Lampe Buero Sued unavailable
title: Buero Sued unavailable
mode: single
if I change state from unavailable to on or off, the message is sent. However with ‘unavailable’ i do not get the message.
When is the condition updated to ‘unavailable’ after the power is switched off? I anticipate, that something has to check the availability periodically, but who and when? Can this be configured?
After thinking of who has to check availability, it occurred to me that support for ‘availability’ has to be done in the zigbee2mqtt integration for the respective bulb (in may case LEDVANCE). Checking this in the page: LEDVANCE AC25702 control via MQTT | Zigbee2MQTT it seems to me, that this is not(yet?) supported. Maybe it can be supported by extending an external converter for this bulb. I will try this way!
You have to enable availability, but it’s supported for any device.
I’d also simplify the automation
- id: '1650729990827'
alias: Buero Sued Ein
description: ''
trigger:
- platform: state
entity_id: light.mqtt_json_light_6
to: 'unavailable'
action:
- service: notify.mobile_app_iphone_von_kurt
data:
message: Lampe Buero Sued unavailable
title: Buero Sued unavailable
mode: single
I think I have enabled availability in zigbee2mqtt configuration yaml file:
homeassistant: false
permit_join: true
mqtt:
base_topic: zigbee2mqtt
server: mqtt://mosquitto
user: (myUserId)
password: (MyPassword)
serial:
port: /dev/ttyACM0
adapter: deconz
availabilty: true # check devices every 10 min to see if online
devices:
'0x0017880108678405':
friendly_name: Motion & Light_Detector
'0x7cb03eaa0014ce29':
friendly_name: Buero_Nord
'0x8418260000012960':
friendly_name: Wohnung_Ost_Sued
'0x84182600000898c9':
friendly_name: Wohnung_West_Sued
'0x84182600000127f3':
friendly_name: Wohnung_West_Nord
'0x841826000001173e':
friendly_name: Wohnung_Ost_Nord
'0xf0d1b80000194614':
friendly_name: Buero_Sued
'0xf0d1b800001c0853':
friendly_name: Hauseingang
'0x841826000000f474':
friendly_name: Gang
still I get no unavailable state (no message) even after your suggested change in automation (but thank you anyway)
Well, first the light has to become unavailable
Did you turn off power to the light and wait for that to happen?
Yes, I turned off power and waited for 40 minutes. I think a lightbulb is an active device which gets polled every 10 minutes!?
Well, it would, if you hadn’t typo’d:
availabilty: true
should be
availability: true
Mea culpa, Of course I have overlooked this typo! I have corrected typo now and wait for result. Will post result anyway. Thank you very much!
Have now corrected type and also changed the delay time between checking of availability in the zigbee2mqtt configuration as follows:
availability: true
# check devices every 10 min to see if online
devices:
'0x0017880108678405':
friendly_name: Motion & Light_Detector
'0x7cb03eaa0014ce29':
friendly_name: Buero_Nord
'0x8418260000012960':
friendly_name: Wohnung_Ost_Sued
'0x84182600000898c9':
friendly_name: Wohnung_West_Sued
'0x84182600000127f3':
friendly_name: Wohnung_West_Nord
'0x841826000001173e':
friendly_name: Wohnung_Ost_Nord
'0xf0d1b80000194614':
friendly_name: Buero_Sued
availability:
timeout: 2
restarted home assistant and waited …
but no response was triggered. The following was recorded in the zigbee2mqtt log when power was cut from the lights (but not on Hauseingang):
Zigbee2MQTT:warn 2022-04-25 12:07:01: Failed to ping 'Hauseingang' (attempt 1/2, Read 0xf0d1b800001c0853/1 genBasic(["zclVersion"], {"sendWhen":"immediate","timeout":10000,"disableResponse":false,"disableRecovery":true,"disableDefaultResponse":true,"direction":0,"srcEndpoint":null,"reservedBits":0,"manufacturerCode":null,"transactionSequenceNumber":null,"writeUndiv":false}) failed (no response received))
Zigbee2MQTT:warn 2022-04-25 12:08:16: Failed to ping 'Gang' (attempt 1/1, Read 0x841826000000f474/3 genBasic(["zclVersion"], {"sendWhen":"immediate","timeout":10000,"disableResponse":false,"disableRecovery":true,"disableDefaultResponse":true,"direction":0,"srcEndpoint":null,"reservedBits":0,"manufacturerCode":null,"transactionSequenceNumber":null,"writeUndiv":false}) failed (no response received))
Zigbee2MQTT:warn 2022-04-25 12:10:24: Failed to ping 'Buero_Sued' (attempt 1/1, Read 0xf0d1b80000194614/1 genBasic(["zclVersion"], {"sendWhen":"immediate","timeout":10000,"disableResponse":false,"disableRecovery":true,"disableDefaultResponse":true,"direction":0,"srcEndpoint":null,"reservedBits":0,"manufacturerCode":null,"transactionSequenceNumber":null,"writeUndiv":false}) failed (no response received))
I have no idea what could be missing or wrong.