[SOLVED] Rules gone after upgrade 2.3 -> 2.5.1

Hi,

does anyone know where did my three rules go during upgrade from 2.3 to 2.5.1? The rules page is empty in PaperUI, and log has this:

2020-02-05 14:27:08.283 [ERROR] [me.storage.json.internal.JsonStorage] - Couldn't deserialize value 'org.eclipse.smarthome.storage.json.internal.Storag
eEntry@643502ba'. Root cause is: org.eclipse.smarthome.automation.Rule cannot be found by org.openhab.core.automation_2.5.0
2020-02-05 14:27:08.285 [ERROR] [me.storage.json.internal.JsonStorage] - Couldn't deserialize value 'org.eclipse.smarthome.storage.json.internal.Storag
eEntry@3196c37d'. Root cause is: org.eclipse.smarthome.automation.Rule cannot be found by org.openhab.core.automation_2.5.0
2020-02-05 14:27:08.287 [ERROR] [me.storage.json.internal.JsonStorage] - Couldn't deserialize value 'org.eclipse.smarthome.storage.json.internal.Storag
eEntry@42c43056'. Root cause is: org.eclipse.smarthome.automation.Rule cannot be found by org.openhab.core.automation_2.5.0

So it’s not finding the rules after update. I cleaned away other errors or warnigns from log regarding rules, but perhaps some files should’ve been moved somewhere during upgrade?

I was running 2.3 and I am now running the 2.5.1 alpine container version of openhab on x86_64.

I can actually see them here: openhab_userdata/jsondb/automation_rules.json, but why don’t system pick them up?

Did you try restarting openHAB?
On my upgrade a restart fixed things. The first time, my Items and Rules files were not read.
Some people say you need to restart up to 3 times.

How did you upgrade? My guess is that you did not use the official update script which would have fixed your rules to work with 2.5. Take a look here, which has an explanation fo the issue and manual steps to correct it…

2 Likes

I just pulled the 2.5.1 container image, and started it with the previous volume mounts. I’d expect the image to run any migration scripts it needs. I need to figure out what to run. I will reread the issue, but doing this didn’t solve it, actually produced lot of errors:

sed -i 's/org.eclipse.smarthome.automation.Rule/org.openhab.core.automation.dto.RuleDTO/' openhab_userdata/jsondb/automation_rules.json

I likely missed something else.

This is the beginning of repeating error:

2020-02-05 16:55:33.796 [ERROR] [org.openhab.core.automation         ] - bundle org.openhab.core.automation:2.5.0 (235)[org.openhab.core.automation.int
ernal.RuleRegistryImpl(210)] : The activate method has thrown an exception                                                                             
java.lang.IllegalArgumentException: Invalid type '{com.google.gson.internal.LinkedTreeMap}' of configuration value!                                    
        at org.eclipse.smarthome.config.core.ConfigUtil.normalizeType(ConfigUtil.java:179) ~[?:?]                                                      
        at org.eclipse.smarthome.config.core.ConfigUtil.normalizeTypes(ConfigUtil.java:153) ~[?:?]                                                     
        at org.eclipse.smarthome.config.core.Configuration.<init>(Configuration.java:75) ~[?:?]                                                                at org.eclipse.smarthome.config.core.Configuration.<init>(Configuration.java:65) ~[?:?]                                                        
        at org.openhab.core.automation.dto.ActionDTOMapper.mapDto(ActionDTOMapper.java:40) ~[?:?]                                                              at org.openhab.core.automation.dto.ActionDTOMapper.mapDto(ActionDTOMapper.java:61) ~[?:?]                                                      
        at org.openhab.core.automation.dto.RuleDTOMapper.map(RuleDTOMapper.java:36) ~[?:?]                                                                     at org.openhab.core.automation.ManagedRuleProvider.toElement(ManagedRuleProvider.java:51) ~[?:?]                                               
        at org.openhab.core.automation.ManagedRuleProvider.toElement(ManagedRuleProvider.java:1) ~[?:?]                                                        at org.eclipse.smarthome.core.common.registry.AbstractManagedProvider.lambda$0(AbstractManagedProvider.java:73) ~[?:?]                         
        at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) ~[?:1.8.0_242]                                                    
        at java.util.concurrent.ConcurrentHashMap$KeySpliterator.forEachRemaining(ConcurrentHashMap.java:3527) ~[?:1.8.0_242]                          
        at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) ~[?:1.8.0_242]                                                        
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) ~[?:1.8.0_242]                                                 
        at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) ~[?:1.8.0_242]                                                           at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:1.8.0_242]                                                        
        at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:566) ~[?:1.8.0_242]
        at org.eclipse.smarthome.core.common.registry.AbstractManagedProvider.getAll(AbstractManagedProvider.java:77) ~[?:?]
        at org.eclipse.smarthome.core.common.registry.AbstractRegistry.addProvider(AbstractRegistry.java:391) ~[?:?]
        at org.openhab.core.automation.internal.RuleRegistryImpl.addProvider(RuleRegistryImpl.java:383) ~[?:?]
        at org.eclipse.smarthome.core.common.registry.AbstractRegistry$ProviderTracker.addingService(AbstractRegistry.java:131) ~[?:?]
        at org.eclipse.smarthome.core.common.registry.AbstractRegistry$ProviderTracker.addingService(AbstractRegistry.java:1) ~[?:?]

I had suggested this, but the maintains chose to go a different direction. TMK, there are no migration scripts that will run unless you use the upgrade script.

I suggest replacing the class name manually. It’s only one file.

If you post or PM me your rule file, I can take a look. OTTOMH, I do not recall any other changes between 2.3 and 2.5 that would affect you, but there may be something else.

Nothing secret here, perhaps it’s a good learning for the ohters too. It is group of rules that shut down or start the lighting based on sunrise / sunset / time. Simple.

{
  "dab67802-13bc-4c07-b597-ab55b60940e2": {
    "class": "org.openhab.core.automation.dto.RuleDTO",
    "value": {
      "triggers": [
        {
          "id": "1",
          "label": "a trigger sun rise channel fires START",
          "description": "React on events from a trigger channel of a thing.",
          "configuration": {
            "properties": {
              "event": "START",
              "channelUID": "astro:sun:local:daylight#event"
            }
          },
          "type": "core.ChannelEventTrigger"
        }
      ],
      "conditions": [],
      "actions": [
        {
          "id": "2",
          "label": "send a command valot OFF",
          "description": "Sends a command to a specified item.",
          "configuration": {
            "properties": {
              "itemName": "valot",
              "command": "OFF"
            }
          },
          "type": "core.ItemCommandAction"
        }
      ],
      "configuration": {
        "properties": {}
      },
      "configDescriptions": [],
      "uid": "dab67802-13bc-4c07-b597-ab55b60940e2",
      "name": "Valojen päiväsammutus",
      "tags": [],
      "visibility": "VISIBLE",
      "description": "Sammutetaan valot kun on jo valoisaa, etteivät yksin pala kotona"
    }
  },
  "rule_2": {
    "class": "org.openhab.core.automation.dto.RuleDTO",
    "value": {
      "triggers": [
        {
          "id": "3",
          "label": "Kun aurinko laskee",
          "description": "React on events from a trigger channel of a thing.",
          "configuration": {
            "properties": {
              "event": "START",
              "channelUID": "astro:sun:local:civilDusk#event"
            }
          },
          "type": "core.ChannelEventTrigger"
        }
      ],
      "conditions": [],
      "actions": [
        {
          "id": "2",
          "label": "Pistä ulkovalot päälle",
          "description": "Pistää rappusten, takapihan ja parvekkeen valot päälle",
          "configuration": {
            "properties": {
              "itemName": "iltavalot",
              "command": "ON"
            }
          },
          "type": "core.ItemCommandAction"
        }
      ],
      "configuration": {
        "properties": {}
      },
      "configDescriptions": [],
      "uid": "rule_2",
      "name": "Ulkovalot päälle",
      "tags": [],
      "visibility": "VISIBLE",
      "description": "Sytyttää valot takapihalle ja parvekkeelle"
    }
  },
  "rule_1": {
    "class": "org.openhab.core.automation.dto.RuleDTO",
    "value": {
      "triggers": [
        {
          "id": "2",
          "label": "Iltasammutus valoille",
          "description": "Sammutetaan tähän aikaan ulkovalot",
          "configuration": {
            "properties": {
              "time": "23:30"
            }
          },
          "type": "timer.TimeOfDayTrigger"
        }
      ],
      "conditions": [],
      "actions": [
        {
          "id": "1",
          "label": "Sammuta takapihan valot",
          "description": "Sammuta takapihan ja parvekkeen valot",
          "configuration": {
            "properties": {
              "itemName": "iltavalot",
              "command": "OFF"
            }
          },
          "type": "core.ItemCommandAction"
        }
      ],
      "configuration": {
        "properties": {}
      },
      "configDescriptions": [],
      "uid": "rule_1",
      "name": "Iltasammutus ulkovaloille",
      "tags": [],
      "visibility": "VISIBLE",
      "description": "Sammuttaa parvekkeen ja takapihan valot"
    }
  }
}

I spotted something else. Take a look at this example…

  "b4962cc4-6067-4b9c-928e-fe3c6065161f": {
    "class": "org.openhab.core.automation.dto.RuleDTO",
    "value": {
      "triggers": [
        {
          "id": "1",
          "label": "a trigger channel fires",
          "description": "React on events from a trigger channel of a thing.",
          "configuration": {
            "event": "START",
            "channelUID": "astro:sun:local:rise#event"
          },
          "type": "core.ChannelEventTrigger"
        }
      ],
      "conditions": [],
      "actions": [
        {
          "inputs": {},
          "id": "2",
          "label": "send a command",
          "description": "Sends a command to a specified item.",
          "configuration": {
            "itemName": "Virtual_Switch_1",
            "command": "OFF"
          },
          "type": "core.ItemCommandAction"
        }
      ],
      "configuration": {},
      "configDescriptions": [],
      "uid": "b4962cc4-6067-4b9c-928e-fe3c6065161f",
      "name": "Channel test",
      "tags": [],
      "visibility": "VISIBLE"
    }
  },

The module configuration entries no longer have a properties key, so you can just remove them and put everything directly under configuration…


{
  "dab67802-13bc-4c07-b597-ab55b60940e2": {
    "class": "org.openhab.core.automation.dto.RuleDTO",
    "value": {
      "triggers": [
        {
          "id": "1",
          "label": "a trigger sun rise channel fires START",
          "description": "React on events from a trigger channel of a thing.",
          "configuration": {
            "event": "START",
            "channelUID": "astro:sun:local:daylight#event"
          },
          "type": "core.ChannelEventTrigger"
        }
      ],
      "conditions": [],
      "actions": [
        {
          "id": "2",
          "label": "send a command valot OFF",
          "description": "Sends a command to a specified item.",
          "configuration": {
            "itemName": "valot",
            "command": "OFF"
          },
          "type": "core.ItemCommandAction"
        }
      ],
      "configuration": {
      },
      "configDescriptions": [],
      "uid": "dab67802-13bc-4c07-b597-ab55b60940e2",
      "name": "Valojen päiväsammutus",
      "tags": [],
      "visibility": "VISIBLE",
      "description": "Sammutetaan valot kun on jo valoisaa, etteivät yksin pala kotona"
    }
  },
  "rule_2": {
    "class": "org.openhab.core.automation.dto.RuleDTO",
    "value": {
      "triggers": [
        {
          "id": "3",
          "label": "Kun aurinko laskee",
          "description": "React on events from a trigger channel of a thing.",
          "configuration": {
            "event": "START",
            "channelUID": "astro:sun:local:civilDusk#event"
          },
          "type": "core.ChannelEventTrigger"
        }
      ],
      "conditions": [],
      "actions": [
        {
          "id": "2",
          "label": "Pistä ulkovalot päälle",
          "description": "Pistää rappusten, takapihan ja parvekkeen valot päälle",
          "configuration": {
            "itemName": "iltavalot",
            "command": "ON"
          },
          "type": "core.ItemCommandAction"
        }
      ],
      "configuration": {
      },
      "configDescriptions": [],
      "uid": "rule_2",
      "name": "Ulkovalot päälle",
      "tags": [],
      "visibility": "VISIBLE",
      "description": "Sytyttää valot takapihalle ja parvekkeelle"
    }
  },
  "rule_1": {
    "class": "org.openhab.core.automation.dto.RuleDTO",
    "value": {
      "triggers": [
        {
          "id": "2",
          "label": "Iltasammutus valoille",
          "description": "Sammutetaan tähän aikaan ulkovalot",
          "configuration": {
            "time": "23:30"
          },
          "type": "timer.TimeOfDayTrigger"
        }
      ],
      "conditions": [],
      "actions": [
        {
          "id": "1",
          "label": "Sammuta takapihan valot",
          "description": "Sammuta takapihan ja parvekkeen valot",
          "configuration": {
            "itemName": "iltavalot",
            "command": "OFF"
          },
          "type": "core.ItemCommandAction"
        }
      ],
      "configuration": {
      },
      "configDescriptions": [],
      "uid": "rule_1",
      "name": "Iltasammutus ulkovaloille",
      "tags": [],
      "visibility": "VISIBLE",
      "description": "Sammuttaa parvekkeen ja takapihan valot"
    }
  }
}

See if that gets them running. If not, I’ll keep looking.

1 Like

yay! now the rules are back. It was the properties, thanks!

2 Likes