added vars:
- $mqtt_client
- $shortName
- $name
They work for publish and publishFile. Self tests:
Helpful post? Buy me a coffee.
- $mqtt_client
- $shortName
- $name
They work for publish and publishFile. Self tests:
Code: C / C++
Czy wolisz polską wersję strony elektroda?
Nie, dziękuję Przekieruj mnie tam// Autoexec file for Etersky WS01, CB3S , with new ha integration and autodiscovery
//Made by Acefx and Google Gemini - Thx to divadiow, benjaminklamerek for the initial source
// and of course p.kaczmarek2 for his wonderfull work, availability, and patience ( with me )
// Set up Aliases
alias Set_Stop backlog setChannel 3 0; setChannel 1 0; setChannel 2 0; setButtonColor 3 CornflowerBlue; setButtonColor 2 CornflowerBlue; setButtonColor 1 CornflowerBlue
alias UPmouv_Stop backlog setChannel 1 0
alias DWmouv_Stop backlog setChannel 3 0
alias Set_Open backlog setChannel 1 1; setButtonColor 1 Coral
alias Set_Close backlog setChannel 3 1; setButtonColor 3 Coral
alias Set_Finish backlog setChannel 2 1; setButtonColor 2 Coral
alias Start_Opening backlog stopAllScripts; startScript autoexec.bat openSkylight
alias Start_Closing backlog stopAllScripts; startScript autoexec.bat closeSkylight
alias Stop_All backlog stopAllScripts; startScript autoexec.bat stopSkylight
alias Stop_led_up backlog setButtonColor 1 Coral
alias Stop_led_finish backlog setButtonColor 2 Coral
alias Stop_led_dw backlog setButtonColor 3 Coral
// create GUI buttons for HTTP panel
startDriver httpButtons
// Define displayed text on button 4/5
setChannelLabel 4 "Shutter travel time (sec)"
setChannelLabel 5 "Backlight"
setButtonEnabled 1 1
setButtonLabel 1 "Open"
setButtonCommand 1 Start_Opening
setButtonColor 1 CornflowerBlue
setButtonEnabled 3 1
setButtonLabel 3 "Close"
setButtonCommand 3 Start_Closing
setButtonColor 3 CornflowerBlue
setButtonEnabled 2 1
setButtonLabel 2 "Stop"
setButtonCommand 2 Stop_All
setButtonColor 2 CornflowerBlue
// Hide the default GUI buttons
setChannelVisible 1 0
setChannelVisible 2 0
setChannelVisible 3 0
SetChannelPrivate 1 1
SetChannelPrivate 2 1
SetChannelPrivate 3 1
// Loading Event Handlers
addEventHandler OnClick 7 Start_Closing
addEventHandler OnClick 24 Start_Opening
addEventHandler OnClick 10 Stop_All
// --- HomeAssistant discovery ---
addEventHandler OnDiscovery 0 publishFile homeassistant/cover/$mqtt_client_cover/config d.json 1
scheduleHADiscovery
// ----------Script part for interlock--------------------------------
// Stop Operation on power up
goto stopSkylight
// do not proceed
return
openSkylight:
DWmouv_Stop
delay_ms 100
Set_Open
publish shutterState opening
setChannel 2 0
setButtonColor 2 CornflowerBlue
delay_s $CH4
Set_Stop
Set_Finish
publish shutterState open
delay_s 2
Set_Stop
return
closeSkylight:
UPmouv_Stop
delay_ms 100
Set_Close
publish shutterState closing
setChannel 2 0
setButtonColor 2 CornflowerBlue
delay_s $CH4
Set_Stop
Set_Finish
publish shutterState closed
delay_s 2
Set_Stop
return
stopSkylight:
Set_Stop
Set_Finish
publish shutterState open
delay_s 6
Set_Stop
return{
"dev": {
"ids": [
"$mqtt_client"
],
"name": "$mqtt_client"
},
"name": "$name",
"~": "$mqtt_client",
"avty_t": "~/connected",
"uniq_id": "$mqtt_client_cover",
"qos": 1,
"unique_id": "$mqtt_client_id",
"device_class": "shutter",
"state_topic": "~/shutterState/get",
"command_topic": "cmnd/$mqtt_client/backlog",
"payload_open": "Start_Opening",
"payload_close": "Start_Closing",
"payload_stop": "Stop_All",
"state_open": "open",
"state_closed": "closed"
}