[SOLVED] How to transform a string item to a switchable one to expose

Hello all,
as i’m walking deeper into the openhab rabbithole, my current endeavour is integrating my 3 perenz 7110 ceiling fans in openhab.
I’m using the broadlink binding currently in beta Broadlink binding for RMx, A1, SPx and MP. Any interest? and is working just fine, “up until” openhab.

let me just give a quick rundown of the funcionalities those fans have:

  • when the wall switch is pressed the fans do not remember their last status, they always reset, on the next power up, to only light ON 100%. the fan itself does not report what is it’s status, it was meant to only blindly follow it’s remote from the current status.
  • integrated dimmer: 2 commands: ON/OFF toggle and dimmer. The On/Off is a single command that toggles/inverts the last state, which is not reported back (but i could in a future development discern thorugh some rules from the z-wave switch that powers it consumption and status). The dimmer’s functionality is based on how long you keep pressed the rf433 remote’s single dimmer button. each time you press it it starts dimming in the opposite direction. in the binding i’ve imported a command that takes the light intensity to about 50%, and sending the same command again it brings it back to 100%.
  • fan: 4 commands: off, 1, 2, 3 (increasing fan speed). in the binding i’ve attempted calling speed 1= ON, as the fans being quite powerful is often enough and would be the default desired speed when wanting to “switch on the fan”
  • integrated led strip /night light: 2 separated commands: On and Off.

It’s funny to me how they decided to have 2 separate commands for the least useful feature(the led strip) and only one toggle for the main light, but it is what it is. When we purchased them they felt very smart, to date they have super silent and powerful fan operations though.

following the binding’s instructions i ended p with this structure:

  • a number of string items that are connected to the command channel of the broadlink item
  • a map of the rf commands
  • a stemap that connects the string items with the map items and converts them into actionable buttons while in simple ui (and in habpanel i guess, didn’t get there as of yet)

My issue:

How to expose the items to iftt/google home in a way that they can be manageable by it through simple ON and OFF commands.
In my understanding, the transformation that is currently operated by the sitemap on top of the string items would need to happen between the string items and a “google home compliant switchable virtual item” and then i woudl expose that and not the string item through openhab cloud.
is this feasible? how to do it? i can’t locate the relevant guide or documentation, if it’s already been written, so in that cas just a pointer woudl help.

here is one of the 3 fans’ entries in the:
*.items file

String    GF_CameraDario_Light   "Luce"              <light>         (GF_CameraDario, gLight)   ["Lighting"]     {channel="broadlink:rm3:b28159ec:command"}
String    GF_CameraDario_Led     "Led"               <moon>          (GF_CameraDario, gLed)     ["Switchable"]   {channel="broadlink:rm3:b28159ec:command"}
String    GF_CameraDario_Fan     "Ventilatore"       <fan_ceiling>   (GF_CameraDario, gFan)     ["Switchable"]   {channel="broadlink:rm3:b28159ec:command"}

*.map file (list of hex commands)

Dario_Luce_Toggle = b20b1c00090f0908100f080f080f080f080f080f08081008100f090f09000100000000000000000000000000
Dario_Led_On = b20e1c00090f090e080f080f090f080f0808100f09081008100f090f09000100000000000000000000000000
Dario_Led_Off = b2211c00090f080f090e080e090f080f090f090810081008100f090f09000100000000000000000000000000
Dario_Dimmer = b2c11c00090f090f0908100f090f090f080f080f08071008100f080f09000100000000000000000000000000
Dario_Vent_Off = b2211c00090e090e080f090e090e0908100f090f09071007100f090e09000100000000000000000000000000
Dario_Vent_1 = b2371c000907100f080e090f080f080f090f090f09071007100e090f08000100000000000000000000000000
Dario_Vent_2 = b1121c00080f080f080f08080f0f080f080f080f08080f080f0f080f08000100000000000000000000000000
Dario_Vent_3 = b2161c00080f080f090e090e0807100f090e090f09081007100f090f09000100000000000000000000000000

*.sitemap file that connects them

Frame  {
        Selection item=GF_CameraDario_Light label="Luce"        icon="light"       mappings=[Dario_Luce_Toggle="ON", Dario_Dimmer="50", Dario_Luce_Toggle="OFF"]
        Switch item=GF_CameraDario_Led      label="Led"         icon="moon"        mappings=[Dario_Led_On="ON", Dario_Led_Off="OFF"]
        Selection item=GF_CameraDario_Fan   label="Ventilatore" icon="fan_ceiling" mappings=[Dario_Vent_3="3", Dario_Vent_2="2", Dario_Vent_1="ON", Dario_Vent_Off="OFF"]

One method:
You could create a new “dummy” (not linked to any binding) Switch Item that you expose to the Cloud Connector (myopenhab) + Google Assistant and write a rule that triggers based on the state of this Item.

something like:

rule    "Trigger internal Items from externally exposed Item"
		Item    GF_CameraDario_Light_Dummy     changed from OFF to ON  

by the way: I don’t think that you can apply ["Switchable"] tags to a String Item (only to https://www.openhab.org/addons/integrations/homekit/#item-configuration)

1 Like

by the way: where do you use the MAP transformation? I didn’t see any reference to it in your Items
I don’t have a Broadlink setup so I don’t know the internal workings of it :slight_smile:

Ty Dim, that’s pretty much what i’m trying to do. But my question is VERY basic. I’m sure i can’t create a dummy item containing a rule from paper ui… how do i go about it?
I can add items in an "dummies.items files, but how to connect them to a rule?

using the Item name like in my rule example (note: the example is very basic and you will need to customize it to your needs)

create a dummy:

Switch GF_CameraDario_Light_Dummy "Dummy to expose" ["Switchable"] 

and use the name in the rule

1 Like

if you scroll towards the end of the sitemap portion, you’ll see the connections to the map file

Thank you very much :slight_smile:

1 Like

that’s not a connection to a MAP transformation
that’s a customization of the Selection and Switch sitemap elements

srry, improper use of naming

question still remains: where/how do you use the MAP transformation file? :slight_smile:

If I am not completly wrong: you don’t need one

The Broadlink device does this for you (association of commands to hex strings to be transmitted over IR)

OHH , see i was going to reply in a totally different direction.
Yes, the broadlink device sends RF433, RF315 and IR commands

well… then why do you have a *.map file in your $OPENHAB_CONF/transform/ folder? :slight_smile:
In theory: it’s not being used

I don’t know how the broadlink binding works… maybe it is used by the binding itself?
can you link to the docs for this binding?

Yes, it is :slight_smile:

yes it is,
and it is handy as well from a beginner’s perspective - as getting the codes is quite a lenghty process, having a milestone halfway to have the hex codes organised helps

This made me realise how verbose what i was jotting down was and how complicated it is going to be for me since each of my rf433 fans has inbuilt dimmer +led strip+fan, and is powered by a z-wave switch which resets it to light on, led off, fan off.

I think i’ll restart with a logic flow diagram XD
not bad for a first rule ever written project.

1 Like