Scenes - how to create scene in OH3?

Hello,
a very beginner’s question:
I am trying to create simple scene:
Name: Evening/Morning
First press: it should close all Blinds in group gBlinds and switch on the Light_Living.
Second press: open all in gBlinds and if the Light_Living is on, switch it off

The idea is to have it in Overview Pannel for easy access later.
Could someone help me where to begin? Is it doable with Rules?

Thank you,
Michal, Slovakia

Yes it is possible to do this via rules, but I would also take it a step further and leverage Astro to obtain sunrise/sunset (offsetting the actual values to ensure it is light enough or dark enough to trigger items) to control the blinds/light so it becomes more automatic.

As for a switch on a dashboard view, you want a item that only defines ON or OFF and base your rule on that trigger to “close the gBlinds group and turn on the light” and doing the reverse if the state of the triggering item is changed to the other state. Might also be worth while to add a small delay when changing the light’s state just to provide light long enough for the blinds to let in enough light.

Another thought is to also leverage a weather binding and make exceptions if you have heavy cloud cover or rain/snow lowering the total amount of light.

Thanks for the ideas, but you are too quick to me. Can you help me with more detailed step-by-step instructions?
What I understood:

  1. Creating a new Item, lets name it LivingR_Day_Night
  2. Rules? I am lost here :slight_smile:

rules can be defined as text file in the /etc/openhab2/rules or with OH3 also in the graphical way via UI.

here is the rule im using which gets executed every night at 5am and switch on the heating, air conditioning, etc
file: /etc/openhab2/rules/premorning.rules

rule "Prepare for morning "
when
     Time cron "0 00 5  ? * *"
then
     hvac_livingroom.sendCommand(1)
     hvac_kitchen.sendCommand(1)
     fan_mode.sendCommand(3)
     ....
end

if you dont want it automatic but you want trigger it via a button, it would look like this

rule "Prepare for morning "
when
     Item LivingR_Day_Night received command ON
then
    hvac_livingroom.sendCommand(1)
    hvac_kitchen.sendCommand(1)
    fan_mode.sendCommand(3)
         ....
end

OK, thanks eugen ,
after some trials, I got my experimental rule working.
Important part of it was to find which command can I use to the specific Item.
Now my Rule looks like this:

triggers:
  - id: "1"
    configuration:
      itemName: LivingR_Day_Night
      command: ON
    type: core.ItemCommandTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      itemName: RoletaZadna_Position
      command: DOWN
    type: core.ItemCommandAction
  - inputs: {}
    id: "3"
    configuration:
      itemName: BWSHP63_state
      command: ON
    type: core.ItemCommandAction

But now the question: how the toggling of the item should looks like?
Thanks,
Michal

it depends how you want to toggle it. using some physical device, using something like homekit/alexa, or using main ui… or a combination of these

First is by main UI to test it, later I will add physical switch (probably xiaomi zigbee). I dont have Alexa yet.

So can anyone help me? I am stucked.
Thanks

if you go in mainUI to your item, you should be able already to switch it on & off, e.g.

there is also way to put it on the hoe page. i dont use it, but it seems to be possible.
here is example i have quickly created:

add this to pages->code

config:
  label: Overview
blocks:
  - component: oh-block
    config: {}
    slots:
      default:
        - component: oh-grid-cells
          config: {}
          slots:
            default:
              - component: oh-cell
                config:
                  header: Scenes
                  icon: oh:light
                  action: toggle
                  item: LivingR_Day_Night
                  title: Scene Good Night
                  stateAsHeader: true
                  expandable: false

should look like this

and you get this toggle on the main page

Thanks for reply!
I am able to roll down the roller and switch the light, with the item LivingR_Day_Night, but I cant toggle it yet. Is something wrong in my configuration (please see upper)?

I have succesfully created a switch on the overview page, but it is not making anything in Run mode. Switch on, or switch off…


EDIT:
log warnings:
2021-01-30 22:20:57.643 [ERROR] [rg.apache.cxf.jaxrs.utils.JAXRSUtils] - No message body reader has been found for class java.lang.String, ContentType: application/octet-stream

2021-01-30 22:20:57.647 [WARN ] [s.impl.WebApplicationExceptionMapper] - javax.ws.rs.WebApplicationException: HTTP 415 Unsupported Media Type

Michal

@yfre,
maybe you can help further?
Thanks

@misko903 im really not an expert for mainUI as i dont use it at all.

try this code, maybe it will get the effect you are looking for

config:
label: Overview
blocks:
  - component: oh-block
    config: {}
    slots:
      default:
        - component: oh-grid-cells
          config: {}
          slots:
            default:
              - component: oh-cell
                config:
                  color: blue
                  header: Scenes
                  action: toggle
                  item: LivingR_Day_Night
                  title: Scene Good Night
                  stateAsHeader: true
                  actionItem: LivingR_Day_Night
                  actionCommand: ON
                  actionCommandAlt: OFF

thanks, I tried it also this way, but it does not work like that.

Is it easier to do it with lets say hardware button? do you have an example?

Thanks,
Michal

what exactly is not working?
can you switch it ON and OFF? does your day rule get triggered by “ON” event and the night rule by “OFF” event?

OK,
I have created two rules, one for ON, one for OFF. It was pretty easy at the end, but important, that i learned the logics behind it.

Test LivingR_Day_Night OFF

triggers:
  - id: "1"
    configuration:
      itemName: LivingR_Day_Night
      command: OFF
    type: core.ItemCommandTrigger
conditions:
  - inputs: {}
    id: "2"
    configuration:
      itemName: BWSHP63_state
      state: ON
      operator: =
    type: core.ItemStateCondition
actions:
  - inputs: {}
    id: "3"
    configuration:
      itemName: BWSHP63_state
      command: OFF
    type: core.ItemCommandAction

Test LivingR_Day_Night ON

triggers:
  - id: "1"
    configuration:
      itemName: LivingR_Day_Night
      command: ON
    type: core.ItemCommandTrigger
conditions:
  - inputs: {}
    id: "2"
    configuration:
      itemName: BWSHP63_state
      state: ON
      operator: "!="
    type: core.ItemStateCondition
actions:
  - inputs: {}
    id: "3"
    configuration:
      command: ON
      itemName: BWSHP63_state
    type: core.ItemCommandAction

Thanks for your help!

2 Likes