My first steps with OpenHab

OK, that’s clear. So in the case of timestamp triggers, “by design” the only way to take advantage of the group functionality would be creating triggers dynamically?

In OH 2.5, yes I think that’s the case. It does look like in OH 3 they created proper events and triggers for members of Groups.

1 Like

Right. I think I’ve fully grasped this trigger business now. I might park the problem for now, since I intend to upgrade to OH3 at some point in the not-too-distant future.

I’ve recreated most of my Zipabox rules in openHab, including control of heating, cooling, ventilation, blinds, awning, Sonos speakers and one or two Z-Wave sockets. I’ll try to add the Alexa skill today (I seem to be in a bit of a pickle because I bought the first Alexa device in the UK, but I’m in Spain. If I go to the Amazon UK page I get “You are not eligible to enable this skill due to geographical restrictions.”. If I go to the Amazon.es page I’m told to go to the UK page. The app goes blank when I select the openHab skill. I’ll try with the tablet, which has a new Android version.)

I’m missing the Fibaro Z-Wave sockets that openHab couldn’t detect properly as a secondary controller. For the moment I’ll leave that until the end, when everything else is ready and I can hopefully switch everything over in a weekend. The Fibaro flood sensors are also missing, but they’re not exactly critical. The non-existent sockets are wrapped in objects so I can reference them in the rest of my code.

To validate the openHab rule calculations, I’m sending the same values from the Zipabox and openHab to side-by-side columns in a Google Sheet every 10 minutes so I can check for errors. It’s an effective method - I’ve already found quite a few bugs.

I’ve managed to get the blinds and awnings to go the desired position purely with timers (they’re “dumb” RTS devices) and I think I’ve cracked getting Sonos to interrupt my music with alert messages, one room at a time.

There’s still quite a lot to do, but maybe in a couple of weeks I’ll be ready to unleash openHab on my flat. Before then I’ll upgrade to OH3, though - no point in introducing another source of bugs after I’ve given it control of my house.

I solved the Alexa thing. Just had to change the country registered in Amazon to the UK, install the skill and then change it back again.

I’ve add WeatherUnlocked weather info and AirVisual weather/pollution info. For now I’ve just ported the functions I used in Google App Script and I call them every ten minutes. No nice bindings or anything. Maybe later.

It seem as if switch/case doesn’t work with strings in JSR223/Javascript. This:

  switch (sAirVisualCode) 
  {
    // Clear sky
    case "01d": 
    case "01n": 
      {
        logInfo("AirVisual weather code matched: clear");
        codeWeather = WeatherCode.CLEAR; 
        break;
      }
    // Few clouds
    case "02d": 
    case "02n": 
      {
        codeWeather = WeatherCode.MOSTLY_SUNNY; 
        break;
      }
    // Scattered clouds
    case "03d": 
    case "03n": 
      {
        codeWeather = WeatherCode.PARTLY_CLOUDY; 
        break;
      }
    // Broken clouds
    case "04d": 
    case "04n": 
      {
        codeWeather = WeatherCode.MOSTLY_CLOUDY; 
        break;
      }
    // Shower rain
    case "09d": 
    case "09n": 
      {
        codeWeather = WeatherCode.SHOWERS; 
        break;
      }
    // Mist
    case "50d": 
    case "50n": 
      {
        codeWeather = WeatherCode.MIST; 
        break;
      }
    // Rain
    case "10d": 
    case "10n": 
      {
        codeWeather = WeatherCode.RAIN; 
        break;
      }
    // Snow
    case "13d": 
    case "13n": 
      {
        codeWeather = WeatherCode.SNOW; 
        break;
      }
    // Thunderstorm
    case "11d": 
    case "11n": 
      {
        codeWeather = WeatherCode.THUNDERSTORM; 
        break;
      }
  } 

always drops through to the default (which I omitted here). It doesn’t matter whether I use single or double quotes. In GaS it works fine. I just converted it to if…then…else :man_shrugging:

Having got my rules to a pretty good place, I started having “out of heap space” and Alexa-related errors which cause the system to collapse within a day or two. I haven’t been able to identify the cause, and going back to an older backup didn’t seem to help. I have still older ones I could try, but from reading around it seems my best bet now is what the Germans call “Flucht nach vorn”, i.e. installing OpenHab 3. I’ve taken a swig of whisky and I’m biting down on a stick. Here goes.

My advice is to take it slow. If you try to move everything over all at once you might become overwhelmed with all that needs to be changed. On-the-other-hand, it might not be so bad. If you try an all at once migration, don’t be afraid to step back if it becomes too much and take a more incremental approach.

The Remote openHAB add-on can be invaluable to run both the old OH 2 instance and the OH 3 instance at the same time as you slowly migrate over to OH 3 while still having a functional system.

1 Like

Thanks. However, I don’t really have a functional system, so there’s not much to lose.

I’ve just run the openhabian update. It seemed to run OK, but then right at the end it gave me a message about the upgrade being interrupted by an error. In the console output I can see:

File srv-openhab\x2daddons.mount: No such file or directory
FAILED (reenable mount units)

That seems to be all. On restarting, I see I’m still on 2.5.9. Is there a log file with more details on how the upgrade failed?

I found this.

/etc/systemd/system/srv-openhab2 does not exist on my system.

Unfortunately I can’t help much with openHABian issues. But this looks like it might be related to that.

Could it be anything to do with having redirected the log files to a USB drive?

I really don’t know but it doesn’t seem like that should be a problem. But any deviations from stock openHABian configuration could cause a problem with the upgrade scripts.

Since the install attempt seems to have reset a few things on the system I ran the OH3 upgrade again. It finished suspiciously quickly and reported no errors. I rebooted and it still says I’m on 2.5.9-1, but the service name has changed (now openhab.service rather than openhab2.service) and I have no idea where the logs are.

Prior to the second install I applied the Samba service improvement since it was suggested in the GitHub bug page, but I doubt this did anything since I think I already had Samba installed - the missing directory didn’t appear.

The UI page looks like the new UI page. So I have no idea what’s going on.

By default the logs are in /var/log/openhab which is one thing that breaks Frontail so watch out for that. I don’t know if the upgrade takes care of modifying Frontails systemd .service file to point to the new location.

When you log in it looks for the currently installed version in $OH_USERDATA/etc/version.properties. I don’t know if the upgrade script modifies the bash .profile or .bashrc files to point to the new location. It might still be reading from /var/lib/openhab2/etc/version.properties instead of the new /var/lib/openhab/etc/version.properties file.

In short, all the openhab2 paths have moved to just openhab.

I see the error:

sed: can't read /var/lib/openhab2/etc/version.properties: No such file or directory

just above the ASCII art

So I have to go and manually modify a file to point to the right place? I can’t see either of those in the home directory.

What’s Frontail, incidentally?