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

Send MQTT messages in the 'Chill Projection Screen' rule #1

Open
slopjong opened this issue Nov 24, 2019 · 0 comments
Open

Send MQTT messages in the 'Chill Projection Screen' rule #1

slopjong opened this issue Nov 24, 2019 · 0 comments

Comments

@slopjong
Copy link
Member

The switches

Switch chill_zone_screen_button_up
    "Screen up"
    { channel="mqtt:topic:chill_zone_screen:up", autoupdate="false" }

Switch chill_zone_screen_button_stop
    "Screen stop"
    { channel="mqtt:topic:chill_zone_screen:stop", autoupdate="false" }

Switch chill_zone_screen_button_down
    "Screen down"
    { channel="mqtt:topic:chill_zone_screen:down", autoupdate="false" }

defined in level2.items can be removed if we changed the rule

rule "Chill Projection Screen"
when
    Item chill_projection_screen received command
then
    switch(receivedCommand.toString.toUpperCase){
        case "UP": {
            chill_zone_screen_button_up.sendCommand("ON")
        }
        case "STOP": {
            chill_zone_screen_button_stop.sendCommand("ON")
        }
        case "DOWN": {
            chill_zone_screen_button_down.sendCommand("ON")
        }
    }
end

to

rule "Chill Projection Screen"
when
    Item chill_projection_screen received command
then
    val mqttActions=getActions("mqtt","mqtt:broker:mosquitto")
    switch(receivedCommand.toString.toUpperCase){
        case "UP": {
            mqttActions.publishMQTT(".../on");
            Thread::sleep(1000)
            mqttActions.publishMQTT(".../off");
        }
        case "STOP": {
            mqttActions.publishMQTT(".../on");
            Thread::sleep(1000)
            mqttActions.publishMQTT(".../off");
        }
        case "DOWN": {
            mqttActions.publishMQTT(".../on");
            Thread::sleep(1000)
            mqttActions.publishMQTT(".../off");
        }
    }
end

by using the MQTT binding v1 in parallel. Then the three rules handling the item changes of the three switches could be removed.

Additionally the sleep isn't necessary if the ESPs are configured by pulsing the output.

@slopjong slopjong changed the title Send MQTT messages in Send MQTT messages in the 'Chill Projection Screen' rule Nov 24, 2019
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

No branches or pull requests

1 participant