In this post I struggled with topic names to get Mqtt to work in HABApp. After getting things working I continued to try to consolidate the status and command topics in one MqttPairItem (based on Sebastians suggestion in that post).
HABApp throws the following error however:
[2025-07-02 23:35:29,448] [ HABApp.Rules] ERROR | File "/etc/openhab/habapp/rules/AircoAutomation.py", line 90, in AircoAutomation.py
[2025-07-02 23:35:29,449] [ HABApp.Rules] ERROR | AircoAutomation()
[2025-07-02 23:35:29,449] [ HABApp.Rules] ERROR | File "/etc/openhab/habapp/rules/AircoAutomation.py", line 55, in __init__
[2025-07-02 23:35:29,449] [ HABApp.Rules] ERROR | self.daikin_ac = MqttPairItem.get_create_item('state/daikinac',write_topic='command/daikinac/control')
[2025-07-02 23:35:29,449] [ HABApp.Rules] ERROR | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[2025-07-02 23:35:29,449] [ HABApp.Rules] ERROR | File "/opt/habapp/lib/python3.11/site-packages/HABApp/mqtt/items/mqtt_pair_item.py", line 48, in get_create_item
[2025-07-02 23:35:29,449] [ HABApp.Rules] ERROR | assert isinstance(item, cls), f'{cls} != {type(item)}'
[2025-07-02 23:35:29,449] [ HABApp.Rules] ERROR | AssertionError: <class 'HABApp.mqtt.items.mqtt_pair_item.MqttPairItem'> != <class 'HABApp.mqtt.items.mqtt_item.MqttItem'>
[2025-07-02 23:35:29,449] [ HABApp.Rule] WARNING | /opt/habapp/lib/python3.11/site-packages/HABApp/rule_manager/rule_file.py:86: RuntimeWarning:coroutine 'HABAppRuleContext.unload_rule' was never awaited
[2025-07-02 23:35:29,449] [ HABApp.Rules] WARNING | Failed to load /etc/openhab/habapp/rules/AircoAutomation.py!
Sebastian suggested the following:
This I did. The error remains.
Following steps were:
- remove the AircoAutomation() instantiation at the end of the file (attempt to prevent loading).
- stop habapp (sudo systemctl stop habapp).
- remove AircoAutomation.py from rules.
- start habapp.
- copy AircoAutomation.py into rules folder.
Observed behaviour: same error.
This is my code (no double MqttItems to my knowledge).
import HABApp
from HABApp.core.items import Item
from HABApp.core.events import ValueChangeEvent, ValueChangeEventFilter
from HABApp.openhab.items import NumberItem, SwitchItem, GroupItem
from HABApp.mqtt.items import MqttPairItem, MqttItem
import datetime
import logging
log = logging.getLogger("RuleLog")
class AircoAutomation(HABApp.Rule):
def __init__(self):
super().__init__()
self.daikin_ac = MqttPairItem.get_create_item('state/daikinac',write_topic='command/daikinac/control')
self.ac_handbediening = SwitchItem.get_item('Daikin_handbediening')
self.roomtemp = NumberItem.get_item('A_Bg_Gang_Multisensor_Sensor_temperature')
self.teruglevering = NumberItem.get_item('P1_Meter_Current_Total_Net_Power')
self.SET_TEMP = 19
self.nu = datetime.datetime.now().time()
self.starttijd = datetime.time(10, 30, 0)
self.stoptijd = datetime.time(16, 30, 0)
self.roomtemp.listen_event(self.change_ac, ValueChangeEventFilter())
self.teruglevering.listen_event(self.change_ac, ValueChangeEventFilter())
def change_ac(self,event: ValueChangeEvent):
if self.roomtemp.value > self.SET_TEMP and self.nu > self.starttijd and self.teruglevering < -100:
if self.ac_handbediening.is_off():
if self.daikin_ac['power'] == False:
self.daikin_ac.publish({"power":True,"temp":self.SET_TEMP,"mode":"C","fan":"A"})
log.info('DAIKIN -- Airconditioner aan.')
if self.nu > self.stoptijd and self.teruglevering > -50:
if self.ac_handbediening.is_off():
if self.daikin_ac['power'] == True:
self.daikin_ac.publish({"power":False})
log.info('DAIKIN -- Airconditioner uit.')
AircoAutomation()
What am I doing wrong?