spacemanspiff2007 / HABApp

Easy home automation with MQTT and/or openHAB
Apache License 2.0
54 stars 23 forks source link

item not initilized after startup #401

Closed UrsusS closed 11 months ago

UrsusS commented 11 months ago

I have at least one switch item where the state in HABApp is deviating from the one in OH after system start.

2023-07-18 18:14:07.294 [INFO ] [HABApp                     ] - HABApp Version 1.1.2
2023-07-18 18:14:07.509 [INFO ] [HABApp.openhab.connection  ] - Connected to OpenHAB version 3.4.4 (Release Build)

The startlevel of OH is 100. Several restarts of HABApp won't help.

The item is not found in the HABApp_events.log but in events.log (after restart of OH). 2023-07-18 18:02:22.511 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'swi_Mower_Wintersleep' changed from NULL to OFF

        WintersleepItem: SwitchItem = SwitchItem("swi_Mower_Wintersleep")
        self.log.info(LOGGER + "{}".format(WintersleepItem.value))

results in 2023-07-18 18:17:40.030 [INFO ] [Rule.TestEnv ] - TestRuleContent: None

{
  "link": "http://192.168.43.7:8080/rest/items/swi_Mower_Wintersleep",
  "state": "OFF",
  "editable": false,
  "type": "Switch",
  "name": "swi_Mower_Wintersleep",
  "label": "Mährlin im Winterschlaf",
  "category": "none",
  "tags": [],
  "groupNames": [
    "gMower",
    "gRestoreOnStartup"
  ]
}
spacemanspiff2007 commented 11 months ago

Could you try getting the items with get_item (as described in the docs)?

winter_sleep_item = SwitchItem.get_item("swi_Mower_Wintersleep")
UrsusS commented 11 months ago

Thanks a lot for your sharp eyes. That was the point, now the consequences in the processes, which seemed to be so illogical, should be gone. Unfortunately, it is valid code, but not working. Sorry for having disturbed you.