- Platform information:
- Hardware: Raspberry Pi Model 3b
- OS: Openhabian
- Java Runtime Environment: openjdk 11.0.18 2023-01-17
- openHAB version: 3.4.1
I have two Sonoff IFAN02 devices flashed with tasmota. I have them connected to OpenHAB through mqtt. Definitions are as follows:
UID: mqtt:topic:xxxx:xxxx
label: Living Room Fan
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:xxxx
location: Living Room Fan
channels:
- id: fan_speed
channelTypeUID: mqtt:string
label: Fan Speed
description: ""
configuration:
allowedStates: 0,1,2,3,+,-
commandTopic: cmnd/living_room_fan/FanSpeed
stateTopic: tele/living_room_fan/STATE
transformationPattern: JSONPATH:$.FanSpeed
off: 0
on: 1
- id: fan_light
channelTypeUID: mqtt:switch
label: Fan Light
description: ""
configuration:
commandTopic: cmnd/living_room_fan/POWER1
stateTopic: tele/living_room_fan/STATE
transformationPattern: JSONPATH:$.POWER1
off: OFF
on: ON
UID: mqtt:topic:yyyy:yyyy
label: Dining Room Fan
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:yyyy
location: Dining Room Fan
channels:
- id: fan_speed
channelTypeUID: mqtt:string
label: Fan Speed
description: ""
configuration:
allowedStates: 0,1,2,3,+,-
commandTopic: cmnd/dining_room_fan/FanSpeed
stateTopic: tele/dining_room_fan/STATE
transformationPattern: JSONPATH:$.FanSpeed
off: 0
on: 1
- id: fan_light
channelTypeUID: mqtt:switch
label: Fan Light
description: ""
configuration:
commandTopic: cmnd/dining_room_fan/POWER1
stateTopic: tele/dining_room_fan/STATE
transformationPattern: JSONPATH:$.POWER1
off: OFF
on: ON
The fan channel has 4 states 0,1,2 and 3
These work as expected. If i change the states, the fans change speed accordingly, as expected.
My intention is to have a group that contains both fan channels. I would like this group to show an aggregation of the values of the 2 fans (MAX, to be exact), and additionally, I would like to use the group to control the fans (For example, if I want to turn all fans off, I send 0 to the group, if I want to set all fans to level 1, I send 1 to the group, etc etc)
My first idea was to create a group of base type string (The fan channels are of type string) and use the MAX function to aggregate the values of the fans. Sadly, this does not work, the result of the aggregation turns up to be a date (?!?!?!?!?)
Then I turned to creating a group of base type number, and use MAX as and aggregation again. When it comes to show the aggregation of the two fan channels, this works perfectly. When both fan channels are 0 (Off), then the group value is 0 and I can interpret this as âEverything is offâ. When one or both fan channels are non-zero, I see the highest value between the fan channels as group aggregation, and this is my expected result also.
The problem comes when i try to control the fans through the group. I can set the group value as 0, 1,2 or 3 using SendCmd, and i can see in the logs that an attempt is made to change the values of the group members:
02:47:23.321 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'main_room_all_fans' received command 1
02:47:23.343 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'dining_room_fan_FanSpeed' received command 1
02:47:23.349 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'living_room_fan_FanSpeed' received command 1
Nothing happens though. The fans do not change state, and the group does not change state either.
I guess i have the following questions:
-Am i supposed to be able to change the value of a group that has an aggregation defined?
-Should I expect the group members to change values too?
-If i am, can someone help me figure out what am i doing wrong?
-Could this have to do with the fact that the group is of basetype integer, and the members are using string types? If that is the case, how can i solve this problem, given that using MAX on basetype string does not appear to work?
Here is a screenshot of the group configuration:
The command i am using to try to change the value of the group is:
sendCmd('main_room_all_fans', '1')
or
sendCmd('main_room_all_fans', '0')
(I did try with or without the quotes surrounding the value i am assigning. Tried no quotes, single quotes and double quotes)
Thanks in advance for any help or pointers you could provide