Ikea Fyrtur always shows as closed - zigbee2mqtt

For devices supporting the Auto Discovery feature. Like ZWaveJS2MQTT, Zigbee2MQTT.

Moderator: leecollings

Post Reply
ksacca
Posts: 80
Joined: Thursday 31 May 2018 21:49
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Ikea Fyrtur always shows as closed - zigbee2mqtt

Post by ksacca »

Hi all,

I'm currently moving my domoticz to a new installation. The main reason is because I'm migrating from openzwave to zwavejs2mqtt.
At the same time, I'm moving my zigbee from the old plugin to mqtt autodiscovery. I never really used zigbee, except for some ikea buttons.

I recently installed a Fyrtur blind, but I'm having some issues getting it to work correctly and I have no idea how to troubleshoot this.
In zigbee2mqtt I can open/close/stop the blind without issues. The device in domoticz is also correctly created using mqtt autodiscovery.

From domoticz, I can also open and close the blind, as well as set a specific position when using blinds percentage. If setup as blinds with stop, the stop button works too. The issue is that the state of the domoticz device never changes (except for the very first time the device gets an update after creation).
In domoticz, the status is always closed. Doesn't matter if I use a remote, the buttons on the blinds or domoticz to open it. The status is always closed. The device is not updated on a state message as the last_update time doesn't change.

Here are the mqtt messages sent by zigbee2mqtt.

Autodiscovery message
topic: zigbee2mqttAD/cover/0x0c4314fffe3fc90a/cover/config

Code: Select all

{
  "availability": [
    {
      "topic": "zigbee2mqtt/bridge/state"
    }
  ],
  "command_topic": "zigbee2mqtt/Gordijn/set",
  "device": {
    "identifiers": [
      "zigbee2mqtt_0x0c4314fffe3fc90a"
    ],
    "manufacturer": "IKEA",
    "model": "FYRTUR roller blind (E1757)",
    "name": "Gordijn",
    "sw_version": "2.3.088"
  },
  "json_attributes_topic": "zigbee2mqtt/Gordijn",
  "name": "Gordijn",
  "position_template": "{{ value_json.position }}",
  "position_topic": "zigbee2mqtt/Gordijn",
  "set_position_template": "{ \"position\": {{ position }} }",
  "set_position_topic": "zigbee2mqtt/Gordijn/set",
  "state_closed": "CLOSE",
  "state_open": "OPEN",
  "state_topic": "zigbee2mqtt/Gordijn",
  "unique_id": "0x0c4314fffe3fc90a_cover_zigbee2mqtt",
  "value_template": "{{ value_json.state }}"
}
Message when blinds are open:
topic: zigbee2mqtt/Gordijn

Code: Select all

{
  "battery": 49,
  "linkquality": 55,
  "position": 100,
  "state": "OPEN",
  "update": {
    "state": "idle"
  },
  "update_available": false
}
Message when blinds are closed:
topic: zigbee2mqtt/Gordijn

Code: Select all

{
  "battery": 49,
  "linkquality": 55,
  "position": 0,
  "state": "CLOSE",
  "update": {
    "state": "idle"
  },
  "update_available": false
}
Message when blinds are at 50%:
topic: zigbee2mqtt/Gordijn

Code: Select all

{
  "battery": 49,
  "linkquality": 55,
  "position": 50,
  "state": "OPEN",
  "update": {
    "state": "idle"
  },
  "update_available": false
}
Did anyone successfully add the fyrtur blinds using zigbee2mqtt and autodiscovery? My shutters in zwavejs2mqtt are working as they should.
I'm using domoticz Version: 2022.1 (build 14498) which is the latest available docker version (updated 11 days ago on https://hub.docker.com/r/domoticz/domoticz). I also tested on the stable release 2022.1 and the latest beta outside of docker.
User avatar
Treve
Posts: 107
Joined: Thursday 05 November 2015 10:37
Target OS: Raspberry Pi / ODroid
Domoticz version: v4.11474
Location: Rotterdam, NL
Contact:

Re: Ikea Fyrtur always shows as closed - zigbee2mqtt

Post by Treve »

I have almost the same problem, i only use the Ikea Tradfri 0.10.7 plugin and Ikea hub. the curtain has three positions 100%, 70% and 55% and physically it works well.

In Domoticz version 2020.x the slider also displayed the correct position.

In versions 2021 and 2022, the problems suddenly appeared.
Physically position 100%, slider is 100% closed.
Physically position 70%, slider is 100% closed.
Physically position 55%, slider is 70% closed.
And in reverse.
- RFXtrx433E,
- AEON Labs ZW090 Z-Stick Gen5 EU
- Hue v2.1
- Raspberry Pi 3 Model B, Raspbian Stretch Full on USB-Stick.
- Domoticz 4.11474
Devices: KaKu, Z-Wave, Hue.

for testing:
Raspberry 4, 2GB, SSD
Domoticz 2022.1
Ikea Hub, Fyrtur curtain
ksacca
Posts: 80
Joined: Thursday 31 May 2018 21:49
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Ikea Fyrtur always shows as closed - zigbee2mqtt

Post by ksacca »

I'm trying to find out what's happening, but I don't know enough about the code. In below log I set the blind to 70% using the slider in domoticz. You clearly see the messages are received by domoticz, but there's only a select query to get the device type and subtype. There's no update happening when an mqtt message witht the level is received, only when the button was pushed in domoticz.

Code: Select all

2022-09-19 10:30:58.999 Debug: MAIN SwitchLight idx:68 cmd:Set Level lvl:70
2022-09-19 10:30:58.999 Debug: Query:SELECT HardwareID,DeviceID,Unit,Type,SubType,SwitchType,AddjValue2,nValue,sValue,Name,Options FROM DeviceStatus WHERE (ID == 68)
2022-09-19 10:30:58.999 Debug: MAIN SwitchLightInt : switchcmd:Set Level level:70 HWid:6 sd:6 0x0c4314fffe3fc90a_cover_zigbee2mqtt 1 244 73 21
2022-09-19 10:30:58.999 Debug: Query:SELECT SwitchType FROM DeviceStatus WHERE (HardwareID==6) AND (DeviceID=='0x0c4314fffe3fc90a_cover_zigbee2mqtt')
2022-09-19 10:30:59.000 Debug: Query:SELECT ID,Name,nValue,sValue,Color,SubType FROM DeviceStatus WHERE (HardwareID==6) AND (DeviceID=='0x0c4314fffe3fc90a_cover_zigbee2mqtt')
2022-09-19 10:30:59.000 Debug: Query:UPDATE DeviceStatus SET nValue=1, LastLevel=70, LastUpdate='2022-09-19 10:30:59' WHERE (ID = 68)
2022-09-19 10:30:59.479 Debug: zigbee: Topic: zigbee2mqtt/Gordijn, Message: {"battery":49,"linkquality":23,"position":70,"state":"OPEN","update":{"state":"idle"},"update_available":false}
2022-09-19 10:30:59.480 Debug: Query:SELECT ID, Name, nValue, sValue, Color, SubType, SwitchType FROM DeviceStatus WHERE (HardwareID==6) AND (DeviceID=='0x0c4314fffe3fc90a_cover_zigbee2mqtt') AND (Unit==1)
2022-09-19 10:31:00.502 Debug: zigbee: Topic: zigbee2mqtt/Gordijn, Message: {"battery":49,"linkquality":26,"position":91,"state":"OPEN","update":{"state":"idle"},"update_available":false}
2022-09-19 10:31:00.503 Debug: Query:SELECT ID, Name, nValue, sValue, Color, SubType, SwitchType FROM DeviceStatus WHERE (HardwareID==6) AND (DeviceID=='0x0c4314fffe3fc90a_cover_zigbee2mqtt') AND (Unit==1)
2022-09-19 10:31:01.533 Debug: zigbee: Topic: zigbee2mqtt/Gordijn, Message: {"battery":49,"linkquality":28,"position":88,"state":"OPEN","update":{"state":"idle"},"update_available":false}
2022-09-19 10:31:01.534 Debug: Query:SELECT ID, Name, nValue, sValue, Color, SubType, SwitchType FROM DeviceStatus WHERE (HardwareID==6) AND (DeviceID=='0x0c4314fffe3fc90a_cover_zigbee2mqtt') AND (Unit==1)
2022-09-19 10:31:02.593 Debug: zigbee: Topic: zigbee2mqtt/Gordijn, Message: {"battery":49,"linkquality":26,"position":84,"state":"OPEN","update":{"state":"idle"},"update_available":false}
2022-09-19 10:31:02.594 Debug: Query:SELECT ID, Name, nValue, sValue, Color, SubType, SwitchType FROM DeviceStatus WHERE (HardwareID==6) AND (DeviceID=='0x0c4314fffe3fc90a_cover_zigbee2mqtt') AND (Unit==1)
2022-09-19 10:31:03.596 Debug: zigbee: Topic: zigbee2mqtt/Gordijn, Message: {"battery":49,"linkquality":26,"position":80,"state":"OPEN","update":{"state":"idle"},"update_available":false}
2022-09-19 10:31:03.597 Debug: Query:SELECT ID, Name, nValue, sValue, Color, SubType, SwitchType FROM DeviceStatus WHERE (HardwareID==6) AND (DeviceID=='0x0c4314fffe3fc90a_cover_zigbee2mqtt') AND (Unit==1)
2022-09-19 10:31:04.628 Debug: zigbee: Topic: zigbee2mqtt/Gordijn, Message: {"battery":49,"linkquality":26,"position":76,"state":"OPEN","update":{"state":"idle"},"update_available":false}
2022-09-19 10:31:04.628 Debug: Query:SELECT ID, Name, nValue, sValue, Color, SubType, SwitchType FROM DeviceStatus WHERE (HardwareID==6) AND (DeviceID=='0x0c4314fffe3fc90a_cover_zigbee2mqtt') AND (Unit==1)
2022-09-19 10:31:05.665 Debug: zigbee: Topic: zigbee2mqtt/Gordijn, Message: {"battery":49,"linkquality":26,"position":72,"state":"OPEN","update":{"state":"idle"},"update_available":false}
2022-09-19 10:31:05.665 Debug: Query:SELECT ID, Name, nValue, sValue, Color, SubType, SwitchType FROM DeviceStatus WHERE (HardwareID==6) AND (DeviceID=='0x0c4314fffe3fc90a_cover_zigbee2mqtt') AND (Unit==1)
2022-09-19 10:31:06.702 Debug: zigbee: Topic: zigbee2mqtt/Gordijn, Message: {"battery":49,"linkquality":26,"position":70,"state":"OPEN","update":{"state":"idle"},"update_available":false}
2022-09-19 10:31:06.702 Debug: Query:SELECT ID, Name, nValue, sValue, Color, SubType, SwitchType FROM DeviceStatus WHERE (HardwareID==6) AND (DeviceID=='0x0c4314fffe3fc90a_cover_zigbee2mqtt') AND (Unit==1)
When I click on open or close, these commands are sent (so level 0 with command open or close):

Code: Select all

http://192.168.0.116:8080/json.htm?type=command&param=switchlight&idx=68&switchcmd=Open&level=0&passcode=
http://192.168.0.116:8080/json.htm?type=command&param=switchlight&idx=68&switchcmd=Close&level=0&passcode=
But I always see that the level that is set is -1

Code: Select all

2022-09-19 11:08:21.732 Debug: MAIN SwitchLight idx:68 cmd:Open lvl:-1
2022-09-19 11:11:56.406 Debug: MAIN SwitchLight idx:68 cmd:Close lvl:-1
According to MQTTAutoDiscover.cpp, level -1 is used for stop:

Code: Select all

else if (command == "Stop")
		{
			level = -1;
			szValue = pSensor->payload_stop;
		}
Only if the value is not equal to -1, the SQL update clause is executed:

Code: Select all

		if (level != -1)
		{
			std::vector<std::vector<std::string>> result;
			result = m_sql.safe_query("SELECT ID,Name,nValue,sValue,Color,SubType FROM DeviceStatus WHERE (HardwareID==%d) AND (DeviceID=='%q')", m_HwdID, pSensor->unique_id.c_str());
			if (!result.empty())
			{
				if (command == "On")
					level = 100;
				else if (command == "Off")
					level = 0;
				if (pSensor->component_type == "cover" && pSensor->unique_id.find("zwavejs2mqtt_") == 0 && level == 99) //GizMoCuz: Is this still needed? (who can debug this?)
					level = 100;
				int nValue = (level > 0) ? 1 : 0;
				m_sql.safe_query(
					"UPDATE DeviceStatus SET nValue=%d, LastLevel=%d, LastUpdate='%s' WHERE (ID = %s)",
					nValue, level, TimeToString(nullptr, TF_DateTime).c_str(), result[0][0].c_str());
			}
		}
		return true;
I'm probably looking in the wrong place, so I'll wait for someone with more knowledge to check this :D .
ksacca
Posts: 80
Joined: Thursday 31 May 2018 21:49
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Ikea Fyrtur always shows as closed - zigbee2mqtt

Post by ksacca »

Hmmm.. disregard my previous comment. I see the level is also -1 for my zwave shutters/blinds, and that works correctly. I was looking at it the wrong way.

In the status message sent by zigbee2mqtt, the level is found in the "position" attribute. But the value template is value_json.value.

I manually published a new configuration using MQTT Explorer, and I replaced

Code: Select all

"value_template": "{{ value_json.state}}"
by

Code: Select all

"value_template": "{{ value_json.position }}"
And now the position and status is reported correctly in domoticz. It's strange, because I tested this in home assistant and it worked using the standard configuration (that's why I didn't look into the autodiscover message). I suppose the configuration will be overwritten on each restart of zigbee2mqtt. Is there a way to set a custom configuration for this device?

Edit: Removing the value_template also allows domoticz to update the state of the blind.
The same issue existed in zwavejs2mqtt (see https://github.com/zwave-js/zwavejs2mqtt/pull/1348) and should also be fixed in zigbee2mqtt (https://github.com/Koenkk/zigbee2mqtt/issues/7680) but apparently it doesn't work in domoticz. Shouldn't domoticz use the position_template instead of the value_template when available?

Edit2: Issue can be solved by adding homeassistant: value_template: null under your device in configuration.yaml.
This wil filter the value_template attribute, and domoticz will correctly update the state.

Code: Select all

devices:
  '0x0c4314fffe3fc90a':
    friendly_name: Gordijn
    homeassistant:
      value_template: null
ksacca
Posts: 80
Joined: Thursday 31 May 2018 21:49
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Ikea Fyrtur always shows as closed - zigbee2mqtt

Post by ksacca »

UPDATE: Issue should be fixed in the latest beta thanks to gizmocus! See https://github.com/domoticz/domoticz/co ... 9f08f55a38 for more information.

There's no need to add value_template: null anymore if you are on a beta version > 11/01/2023.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest