Fire channel event in rule without adding this channel to an item

Hello,

unfortunately I wasn’t able to find any informations if it is possible to trigger a channel state request direct in a rule without adding the channel to an item.

rule “Öltank Anfragen”
when
Time cron “0 0 * * * ?”
then
sendCommand(Oeltank_Abfrage, ON) //This would be the one with an item, but the item is really only added for this request, so may be we can do something like that:
askChannel(“mysensors:waterMeter:gateway:Tank_Oel_Vorne:status”,1)
end

I have a few nodes in my household where we need to check from time to time some informations and usual it’s not necessary to add only for the request an item.

If we can’t trigger direct an channel request, is there another way to to that without adding an item?

Vielen Dank für die Hilfe

Jan

Why are you trying to avoid Items, what benefit do you expect? It’s the core of openHAB, it’s internal model of the world. If you have something you want to command or interrogate, and some data in response … this is exactly what an Item is for.

1 Like

Hey,

you can easily check in a rule without adding an item, if the channel triggered something:

Channel "mihome:sensor_switch:158d00016d8747:button" triggered SHORT_PRESSED

So

is not that 100% right. You can also get status updates direct in a rule, without adding an item.

The benefit is really simple:

  1. When I change the item files, the Homekit binding is always forgetting in homekit all locations of the items. This is a known issue and really annoying.
  2. I have almost 50 MySensor nodes at our ground. A lot simple requests with HC-SR04 Sensors. There are simple requests like filling level of the oil tank, from water tanks, cars in the garages,… and so on. The states I have to request. It’s spamming up my items file a lot when I’m adding for every request a single item.

Having hundreds of Items is okay and quite normal. You only have to set them up once.
It brings the benefits of display via the various UIs. It brings the benefits of being able to look at the stored state at any time, not just at device update time. It brings the benefit of managing via Groups. It brings the benefit of issuing commands (including REFRESH) which is the one you want I guess :slight_smile:

Example, with Items you can have one rule issuing commands to many Items of a Group.

I don’t think there’s any technical reason to prohibit writing to channels from rules. I think it may be a forthcoming feature of NRE (New Rule Engine)?

I can’t imagine one.

1 Like

Only for Thing Channels that represent momentary events like a button press. Any Channel that has a state MUST be linked to an Item to be used anywhere within OH.

Only the online/offline status of a Thing. Any other state MUST be linked to an Item.

That is how OH works.

This needs to be fixed in the Homekit binding. It is a bug. Have you opened an issue for this?

I don’t understand. What do you mean by “spamming”?

No. That isn’t how OH is built to work. Items are what OH works on. Except for the two examples above (momentary stateless events and Thing’s Online status) the only way to command something or read and use the state of something is by linking a Channel to an Item.

Items are the model of your home automation. Items are where you convert some:random:incomprehensible:channel:id to “The Front Room Lamp’s switch”. Items are where you define how to interact with a device (i.e. the Item Type), what it looks like on your UIs, and what it means in the context of your home automation. Things are not intended to be used alone.

You could use MQTT action

eg.

val mqttActions = getActions("mqtt","mqtt:broker:myUnsecureBroker")
mqttActions.publishMQTT("zigbee2mqtt/0x00AAAAAAAAAA/get/state","true")

This save you to create a channel in things, then create an item, then triggered by sendCommand().

Saying that, if using things, items correctly, then sendCommand is actually pretty easy too.

Welcome Eric and thank you for your contribution but this is a old thread