In the process of migrating one of my old textual rules to UI rules, I thought I might have found a way to eliminate two simple rules and have the Astro binding control a switch.
Textual rules:
rule "Sunrise Rule"
when Channel "astro:sun:local:rise#event" triggered START
then DaylightHours.postUpdate("ON")
end
rule "Sunset Rule"
when Channel "astro:sun:local:set#event" triggered START
then DaylightHours.postUpdate("OFF")
end
I was hoping to use the Astro Binding Local Sun Thing channel Daylight / Range event to switch the DaylightHours switch item. I was encouraged when I tried to Link a new item to the channel in the UI and the default Type was switch. But when I try to Link an item (new or existing) to the channel, I get an error “There is no profile available for the selected item.”
Here is what the Link channel to item screen looks like:
There are two profiles listed, but they are not clickable. It seems like what I need is a profile that uses the START and END triggers to turn the switch item ON and OFF.
I feel like I’m missing something, but perhaps it is not intended to work the way that I want it to.
Here is my system information
runtimeInfo:
version: 3.4.0.M1
buildString: Milestone Build
locale: en-US
systemInfo:
configFolder: /etc/openhab
userdataFolder: /var/lib/openhab
logFolder: /var/log/openhab
javaVersion: 11.0.16
javaVendor: Raspbian
osName: Linux
osVersion: 5.15.61-v7l+
osArchitecture: arm
availableProcessors: 4
freeMemory: 643935800
totalMemory: 1021313024
startLevel: 70
bindings:
- amazonechocontrol
- astro
- denonmarantz
- harmonyhub
- icalendar
- icloud
- ipcamera
- mail
- mqtt
- myq
- network
- omatic
- openweathermap
- remoteopenhab
- tplinksmarthome
- tuya
- zwave
clientInfo:
device:
ios: false
android: false
androidChrome: false
desktop: true
iphone: false
ipod: false
ipad: false
edge: false
ie: false
firefox: false
macos: false
windows: true
cordova: false
phonegap: false
electron: false
nwjs: false
webView: false
webview: false
standalone: false
os: windows
pixelRatio: 1.5
prefersColorScheme: light
isSecureContext: false
locationbarVisible: true
menubarVisible: true
navigator:
cookieEnabled: true
deviceMemory: N/A
hardwareConcurrency: 4
language: en-US
languages:
- en-US
onLine: true
platform: Win32
screen:
width: 1707
height: 1067
colorDepth: 24
support:
touch: false
pointerEvents: true
observer: true
passiveListener: true
gestures: false
intersectionObserver: true
themeOptions:
dark: light
filled: true
pageTransitionAnimation: default
bars: filled
homeNavbar: default
homeBackground: default
expandableCardAnimation: default
userAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML,
like Gecko) Chrome/105.0.0.0 Safari/537.36
timestamp: 2022-09-13T14:03:40.234Z
If this doesn’t work, then I will use a single rule to replace the two textual rules:
configuration: {}
triggers:
- id: "1"
configuration:
thingUID: astro:sun:local
event: ""
channelUID: astro:sun:local:daylight#event
type: core.ChannelEventTrigger
conditions: []
actions:
- inputs: {}
id: "2"
configuration:
blockSource: <xml xmlns="https://developers.google.com/blockly/xml"><block
type="controls_if" id="|V6kOOKLg4h)v9lzNJ]S" x="59" y="85"><mutation
elseif="1"></mutation><value name="IF0"><block type="logic_compare"
id="@j3g=;_WNgbjNgGi|.,A"><field name="OP">EQ</field><value
name="A"><block type="oh_context_info" id="ayDnq:ZdKIn;PBvw+52Z"><field
name="contextInfo">event</field></block></value><value name="B"><block
type="text" id="UZ7En/{z(n~^W?l]I0*-"><field
name="TEXT">START</field></block></value></block></value><statement
name="DO0"><block type="oh_event" id="fIH3|PKr6tRD{y=]h%$+"><field
name="eventType">sendCommand</field><value name="value"><shadow
type="text" id="P[RLAQUf3ZP{9478d,Ua"><field
name="TEXT">ON</field></shadow></value><value name="itemName"><shadow
type="oh_item" id="`F5^;:]b0XrtM?%VM-t:"><field
name="itemName">DaylightHours</field></shadow></value></block></statement><value
name="IF1"><block type="logic_compare" id="9i*6w-12DQ$FKBd!VC[/"><field
name="OP">EQ</field><value name="A"><block type="oh_context_info"
id="`]A;x^{{4tfdro[kX#yB"><field
name="contextInfo">event</field></block></value><value name="B"><block
type="text" id="LS+P]:2v7A73;]tuZm*C"><field
name="TEXT">END</field></block></value></block></value><statement
name="DO1"><block type="oh_event" id="Ap^slRWs-.Q|FRFN=ir0"><field
name="eventType">sendCommand</field><value name="value"><shadow
type="text" id="qbRwEDA:CJEVo^F+h)mp"><field
name="TEXT">OFF</field></shadow></value><value name="itemName"><shadow
type="oh_item" id="![qp^+2j|E7Li5cJkM2+"><field
name="itemName">DaylightHours</field></shadow></value></block></statement></block></xml>
type: application/javascript
script: |
if (event.event == 'START') {
events.sendCommand('DaylightHours', 'ON');
} else if (event.event == 'END') {
events.sendCommand('DaylightHours', 'OFF');
}
type: script.ScriptAction
Blockly image:
Thanks in advance for any suggestions and help.