HABApp - Easy automation with openHAB

Hi Sebastian - quick and possibly dumb question. How do I create an event listener that is triggered only by a command sent to an item, and not mere updates? ValueUpdateEvent and ValueChangeEvent seems to be triggered by updates and commands.

thanks!

Dan

Use HABApp.openhab.events.ItemCommandEvent as an event filter.

ValueUpdateEvent gets triggered by an ItemStateEvent, since the latter is a subclass of the former.

In the Example 1 the last listener uses it.

thank you again!

hello @Spaceman_Spiff i’ve noticed an error while creating item tags: it doesn’t properly set values in example:

create items:

  • type: Group
    name: ‘{thing_label, “\s+”, “"}’
    label: '{thing_label, “\s+”, "
    ”}’
    groups: [‘gThermostats’]
    tags: [‘HVAC’]
    metadata:
    model: ‘ZTEMP2’

creates
Group termostatoMatrimoniale “termostatoMatrimoniale” (gThermostats) [HVAC] {model=“ZTEMP2”}

instead of

Group termostatoMatrimoniale “termostatoMatrimoniale” (gThermostats) [“HVAC”] {model=“ZTEMP2”}

so the semantic model doesn’t working properly. did you already know it? is there a way to fix this?
thanks in advace

No, just heard of it

Is this only a problem with the generated *.items file or an actual problem with the generated item?

HABApp 0.30.1 is out!

@domoticaundici
The new version fixes your issue, it was just with the generated file, the item was created correctly.

1 Like

hello @Spaceman_Spiff ! many many thanks! it works great now

Troubles installing HABapp.
I’m trying to give HABApp a try but I am unable to install it. I am using OH3 on a raspberry pi 3 v1.2 with an openhabian image. I upgraded through openhabian-config to version 3.1 milestone 4. The openhabian script updated itself today. I also performed an update of raspberry-pi os, always through the openhabian interface

Installing HABApp always give an error. I set the debug log to maximum and it turns out that there is an error when performing pip install habapp. I therefore tried to issue directly the command

 sudo  python3 -m pip install  habapp

But it always end up with an error about a directory not found. Maybe it is a silly mistake but I can’t figure out how to proceed. I would like to avoid starting completely fresh with a new openhabian install, if possible.
The output of the pip command is the following

 sudo  python3 -m pip install  habapp
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting habapp
  Using cached https://files.pythonhosted.org/packages/b3/71/6947575f5004c5abd6badf07f4b05edbb7c10cce1ce626552a132dd42017/HABApp-0.30.1-py3-none-any.whl
Collecting pendulum==2.1.2 (from habapp)
  Using cached https://files.pythonhosted.org/packages/db/15/6e89ae7cde7907118769ed3d2481566d05b5fd362724025198bb95faf599/pendulum-2.1.2.tar.gz
  Installing build dependencies ... done
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/usr/lib/python3.7/tokenize.py", line 447, in open
        buffer = _builtin_open(filename, 'rb')
    FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-install-dbvsk_wj/pendulum/setup.py'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-dbvsk_wj/pendulum/
o

Can you give some hint?
Thank you

The version of pip is too old - you have to upgrade it first:

python -m pip install --upgrade pip
1 Like

Thanks for your answer. I actually had to use a slightly different syntax

python3 -m pip install --upgrade pip

But then the openhabian menu to install hab app still give the same error.
Strange enough if I issue the install command directly,

 python3 -m pip install --upgrade habapp

it installs everything.
I am wondering wether there is some issue with openhbian installing packages as superuser.

At the end of the installation as normal user, I get some warnings,

  WARNING: The script watchmedo is installed in '/home/openhabian/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The script habapp is installed in '/home/openhabian/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

Are these warnings significant?

1 Like

I was under the impression that you are working with the instruction and are working in the venv.
If you follow the instructions there will be no warning and everything works fine!
Please don’t try anythign else!

I followed instructions and the warnings are gone. Thanks

create_channel_link geves an error. trying to execute

itemName=“adesso”
if not HABApp.openhab.interface.item_exists(itemName):
HABApp.openhab.interface.create_item(“DateTime”, itemName, label=‘Data e ora’, category=‘time’, tags=[], groups=[], group_type=’’, group_function=’’, group_function_params=[])if HABApp.openhab.interface.item_exists(itemName) and not HABApp.openhab.interface.channel_link_exists(“ntp:ntp:local:dateTime”, itemName):
HABApp.openhab.interface.create_channel_link(“ntp:ntp:local:dateTime”, itemName)

unable to create items with starting capital

HABApp.openhab.interface.create_item(‘Number’, ‘HABApp_Ping’, label=‘HABApp_Ping’, category=’’, tags=[], groups=[], group_type=’’, group_function=’’, group_function_params=[])

replacing HABApp_Ping with habAppPing (also in config.yml) works perfectly

This definitely works, there is probably something else wrong.
Can you please use proper code fences, post the complete rule and the corresponding log entries?
Posting just the snippets makes me think that you try to run these themselves wich you should not.

when habAppPing was HABApp_Ping didn’t worked for me :thinking:

  • There is no need to modify sys.path - don’t do it!
  • You have not used Backticks ``` as a code fence, this is a screenshot
  • You have not shown the log entry, if there is an error HABApp will generate a log entry.
    How am I supposed to see what is wrong from a screenshot?
  • In a rule you use self.oh or self.openhab instead of HABApp.openhab.interface

Yes, Sir :slight_smile: i will improve my coding skills. i’ve started some days ago with habapp and is very useful. thanks for your work! anyway go straight to the problem

when i issue the command
HABApp.openhab.interface.create_item(‘Number’, ‘HABApp_Ping’, label=‘HABApp_Ping’, category=‘’, tags=, groups=, group_type=‘’, group_function=‘’, group_function_params=)

log says

2021-05-13 16:48:56.972 [WARN ] [rest.core.internal.item.ItemResource] - Received HTTP PUT request at ‘items/HABApp_Ping/’ with an invalid item name ‘HABApp_Ping’.

For me this works:

self.openhab.create_item('Number', 'HABApp_Ping')

Are you sure there aren’t any special characters?
Also please check the HABApp.log

copy/paste of your line → same result
==> /var/log/openhab/openhab.log <==

2021-05-13 17:37:34.837 [WARN ] [rest.core.internal.item.ItemResource] - Received HTTP PUT request at ‘items/HABApp_Ping/’ with an invalid item name ‘HABApp_Ping’.