alexander-vitishchenko / hc3-to-mqtt

Fibaro HC3 integration with Home Assistant & NodeRed
MIT License
31 stars 13 forks source link

Cover state does not update #53

Closed jthun closed 1 year ago

jthun commented 1 year ago

Describe the bug Hi! To start with, I love this QA!

The cover state on all my covers, however, is always Unknown and never updated to Closed or Opened. The MQTT topic homeassistant/cover/732/events/fibaro => home assistant/value is properly updated when closing/opening, but homeassistant/cover/732/events/fibaro => home assistant/state never changes.

Environment:

MQTT Logs

config:

{
    "availability": [
        {
            "payload_available": "online",
            "payload_not_available": "offline",
            "topic": "homeassistant/hc3-status"
        },
        {
            "payload_available": "false",
            "payload_not_available": "true",
            "topic": "homeassistant/cover/732/events/fibaro => home assistant/dead",
            "value_template": "{{ value_json.value }}"
        }
    ],
    "availability_mode": "all",
    "command_topic": "homeassistant/cover/732/events/home assistant => fibaro/action",
    "device": {
        "configuration_url": "http://REDACTED/app/settings/devices/list#device-729",
        "hw_version": "Z-Wave type 3; Z-Wave version 3.52",
        "identifiers": "hc3-729",
        "manufacturer": "Fibargroup",
        "model": "",
        "name": "709",
        "suggested_area": "Default Room",
        "sw_version": "Fibargroup 25.25"
    },
    "json_attributes_topic": "homeassistant/cover/732/config_json_attributes",
    "name": "Markisen",
    "object_id": "732",
    "payload_close": "close",
    "payload_open": "open",
    "payload_stop": "stop",
    "position_template": "{{ value_json.value }}",
    "position_topic": "homeassistant/cover/732/events/fibaro => home assistant/value",
    "set_position_topic": "homeassistant/cover/732/events/home assistant => fibaro/value",
    "state_closed": "Closed",
    "state_closing": "Closing",
    "state_open": "Opened",
    "state_opening": "Opening",
    "state_topic": "homeassistant/cover/732/events/home assistant => fibaro/state",
    "tilt_closed_value": 0,
    "tilt_command_topic": "homeassistant/cover/732/events/home assistant => fibaro/value2",
    "tilt_opened_value": 100,
    "tilt_status_template": "{{ value_json.value }}",
    "tilt_status_topic": "homeassistant/cover/732/events/fibaro => home assistant/value2",
    "unique_id": "732",
    "value_template": "{{ value_json.value }}"
}

config_json_attributes:

{
    "actions": {
        "setFavoritePosition": 1
    },
    "baseType": "com.fibaro.baseShutter",
    "configXml": false,
    "created": 1650281079,
    "enabled": true,
    "hasUIView": true,
    "id": 732,
    "interfaces": [
        "deviceGrouping",
        "energy",
        "favoritePosition",
        "favoritePositions",
        "levelChange",
        "power",
        "zwave",
        "zwaveMultiChannelAssociation",
        "zwaveProtection",
        "zwaveSceneActivation"
    ],
    "isPlugin": false,
    "modified": 1678098894,
    "name": "Markisen",
    "parentId": 729,
    "properties": {
        "RFProtectionState": 0,
        "RFProtectionSupport": 3,
        "categories": [
            "blinds"
        ],
        "configured": true,
        "dead": false,
        "deadReason": "",
        "deviceControlType": 54,
        "deviceGroup": [],
        "deviceGroupMaster": 0,
        "deviceIcon": 87,
        "deviceRole": "BlindsWithPositioning",
        "emailNotificationID": 0,
        "emailNotificationType": 0,
        "endPointId": 0,
        "energy": 0.22,
        "favoritePositions": [
            {
                "label": "Favorite position 1",
                "name": "favoritePosition1",
                "value": 50
            }
        ],
        "favoritePositionsNativeSupport": false,
        "icon": {
            "path": "/assets/icon/fibaro/roleta/roleta100.png",
            "source": "HC"
        },
        "includeInEnergyPanel": true,
        "localProtectionState": 0,
        "localProtectionSupport": 5,
        "log": "",
        "logTemp": "",
        "manufacturer": "",
        "markAsDead": true,
        "model": "",
        "nodeId": 147,
        "parametersTemplate": 721,
        "pollingTimeSec": 0,
        "power": 0.0,
        "productInfo": "1,15,3,2,16,0,25,25",
        "protectionExclusiveControl": 0,
        "protectionExclusiveControlSupport": false,
        "protectionLocal": 0,
        "protectionLocalSupport": 5,
        "protectionRF": 0,
        "protectionRFSupport": 3,
        "protectionState": 0,
        "protectionTimeout": 0,
        "protectionTimeoutSupport": false,
        "pushNotificationID": 0,
        "pushNotificationType": 0,
        "remoteGatewayId": 0,
        "saveLogs": true,
        "saveToEnergyPanel": false,
        "sceneActivation": 0,
        "serialNumber": "",
        "showEnergy": true,
        "smsNotificationID": 0,
        "smsNotificationType": 0,
        "state": "Unknown",
        "storeEnergyData": false,
        "supportedDeviceRoles": [
            "BlindsWithPositioning",
            "BlindsWithoutPositioning",
            "VenetianBlinds",
            "GateWithoutPositioning",
            "GateWithPositioning"
        ],
        "useTemplate": true,
        "userDescription": "",
        "value": 99,
        "value2": 0,
        "zwaveCompany": "Fibargroup",
        "zwaveInfo": "3,3,52",
        "zwaveVersion": "25.25"
    },
    "roomID": 232,
    "roomName": "Sovrummet",
    "sortOrder": 71,
    "type": "com.fibaro.FGRM222",
    "view": [
        {
            "assetsPath": "dynamic-plugins/com.fibaro.rollerShutter",
            "name": "com.fibaro.rollerShutter",
            "translatesPath": "/assets/i18n/com.fibaro.rollerShutter",
            "type": "ts"
        },
        {
            "assetsPath": "dynamic-plugins/energy",
            "name": "energy",
            "translatesPath": "/assets/i18n/energy",
            "type": "ts"
        },
        {
            "assetsPath": "dynamic-plugins/favorite-positions",
            "name": "favorite-positions",
            "translatesPath": "/assets/i18n/favorite-positions",
            "type": "ts"
        },
        {
            "assetsPath": "",
            "name": "level-change",
            "translatesPath": "/assets/i18n/level-change",
            "type": "ts"
        },
        {
            "assetsPath": "dynamic-plugins/power",
            "name": "power",
            "translatesPath": "/assets/i18n/power",
            "type": "ts"
        }
    ],
    "viewXml": false,
    "visible": true
}
alexander-vitishchenko commented 1 year ago

Hi @jthun,

It looks like you cover Fibaro/FGRM222 device advertises "Uknown" state (not Open/Closed), and it relies on cover position property instead with [0..100] values.

  1. I would expect the device to advertise its state properly, and if Fibaro cannot do it for any reason, I can add a heuristic algorithm to the QuickApp and replace "Unknown" state with Open/Closed depending on it's 0 or 100 numeric position.

  2. Can you please clarify how cover device looks at your Home Assistant UI, can you manage cover position, and the only issue you have is the "Unknown" state label?

  3. Does your cover support blinds/tilt positioning too?

jthun commented 1 year ago

Hi!

  1. In Fibaro it says "Closed" or "Opened", together with the percentage (99%). I can control it properly from Fibaro (and from HA), but it won't open 100%, only 99%. The only issue is the state change in HA since the MQTT state topic is not updated. The percentage is sent properly to the fibaro => home assistant value topic.
image image
  1. Not that I know of. I only have vertical blinds and awnings. Like these ones.

image

alexander-vitishchenko commented 1 year ago

Hi @jthun,

Thank you. The JSON files that you shared earlier indicate the "Unknown" state for the cover. It looks like Fibaro UI renders Open/Closed label based on the cover position attribute [0..100], not based on the state attribute (like I do)

Can you please advise how your cover is rendered at Home Assistant UI (not at Fibaro UI)?

And when you use Home Assistant UI, and change the slider position for cover - do you see this change reflected at Fibaro?

jthun commented 1 year ago

Hi!

I use several different cards in Home Assistant, and they all say Unknown (Okänd in Swedish).

image image

Fibaro is properly updated with slider position when I change it from Home Assistant, but the state never changes on either side.

jthun commented 1 year ago

I've checked the HC3/api/devices/DEVICE_ID endpoint, and it always says that state = Unknown, no matter what, so this problem is clearly on the Fibaro side of things.

alexander-vitishchenko commented 1 year ago

I can implement the newer version of the QuickApp that will be broadcasting Open/Closed state based on the numeric position when Fibaro uses "Unknown" state.

You can test it later today/tomorrow.

jthun commented 1 year ago

Any progress on this? States in HA would be really nice to have.

alexander-vitishchenko commented 1 year ago

Sorry, got the emerging priority/business trip to the United State, but hope to be back within 1-2 weeks time

rwijbenga commented 1 year ago

Any progress on this. :) Would be handy...

alexander-vitishchenko commented 1 year ago

I finished the implementation last week, but it didn't work as expected at my demo lab, so I continue debugging this Sunday and hope to come back with resolution

rwijbenga commented 1 year ago

Will keep my fingers crossed!!

alexander-vitishchenko commented 1 year ago

Hi @rwijbenga, @jthun,

I've finally got the implementation work in my local environment, and published new 1.0.232 version, please check it out and let me know if it works for you

rwijbenga commented 1 year ago

Works here ! Super !! :)

jthun commented 1 year ago

Works really well! The only thing my HA complained about now was that the illuminance sensor had a unit of measurement = lux, when HA was expecting lx. I fixed that with self.bridgeUnitOfMeasurement = "lx" on line 293 in device_api.lua.

Many thanks!

alexander-vitishchenko commented 1 year ago

I'll change lux to lx and publish new version today/this weekend