Vacuum Robter Zone Cleaning Rule

Had a working Zone cleaning Rule under OH2.5 now i upgraded to latest OH3 and this rule does not work anymore beside Clean all:

// ----------------------------------------------------------------------------
rule "zone control - zone selection"
// ----------------------------------------------------------------------------
when 
    Member of gZoneSwitch received update
then
    logInfo("zone.rules", "update received from item: " + triggeringItem)

    val zoneSwitch = triggeringItem as SwitchItem
    val lastUpdate = now

    zoneSwitch.getGroupNames().forEach[groupName | 
        
        if (groupName != "gZoneLastSwitch")
        {
            logDebug("zone.rules", "find related members of " + groupName + " in other group gZoneLastUpdate from triggering item " + triggeringItem.name)

            gZoneLastUpdate.members.filter[updateItem | !updateItem.getGroupNames.contains(groupName)].forEach[ updateItem | 
                logInfo("zone.rules", "posting update to " + updateItem.name)
                updateItem.postUpdate(lastUpdate.toString())
            ]
        }
        else
        {
            logDebug("zone.rules", "ignoring group " + groupName) 
        }
    ]
end

// ----------------------------------------------------------------------------
rule "zone control - action"
// ----------------------------------------------------------------------------
when 
    Item zoneAction received command
then
    logInfo("zone.rules", "zoneAction command received: " + receivedCommand)

    var StringBuilder zoneCmd = new StringBuilder
    var StringBuilder roomCmd = new StringBuilder

    // use this to get the room numbers
    // XiaVac_action_Command.sendCommand("get_room_mapping[]")

    if (gAllZones.state == ON)
    {
        logInfo("zone.rules", "sending cmd to device: app_start")
        XiaVac_action_Command.sendCommand("app_start")
        return;
     }

    // sort by timestamp and loop throug items
    gZoneLastUpdate.members.sortBy[(state as DateTimeType).getZonedDateTime.toInstant.toEpochMilli].forEach[zoneLastUpdateItem | 
        logDebug("zone.rules", "--> "+ zoneLastUpdateItem)

        // loop until we find the right group...
        zoneLastUpdateItem.getGroupNames().forEach[groupName | 
            logDebug("zone.rules", "----> "+ groupName)
            if (groupName != "gZoneLastUpdate")
            {
                logDebug("zone.rules", "find related members of " + groupName + " in other group gZoneSwitch")

                // find the switch item from the same room group
                gZoneSwitch.members.filter[zoneSwitchItem | 
                            zoneSwitchItem.getGroupNames.contains(groupName)
                        &&  zoneSwitchItem.getGroupNames.contains("gZoneSwitch")].forEach[ zoneSwitchItem | 
                    
                    logDebug("zone.rules", "found related switch item " + zoneSwitchItem.name + " with state " + zoneSwitchItem.state)
                    
                    if (zoneSwitchItem.state == ON)
                    {
                        var zoneType = transform("MAP", "robo_room_coordinates.map", zoneSwitchItem.name + "#type")
                        var zoneCoordinates = transform("MAP", "robo_room_coordinates.map", zoneSwitchItem.name + "#coordinates")

                        logInfo("zone.rules", zoneCoordinates + "-" + zoneSwitchItem.name + " is ON. {zoneType:" + zoneType + "; zoneCoordinates: " + zoneCoordinates + "}")

                        // not sure if we can assign a new var by reference, so to be safe, just use if..else and duplicate code
                        if (zoneType == "zone")
                        {
                            if (zoneCmd.length == 0)
                            {
                                zoneCmd.append("app_zoned_clean[")
                            }

                            zoneCmd.append(zoneCoordinates)
                        }
                        else if (zoneType == "room")
                        {
                            if (roomCmd.length == 0)
                            {
                                roomCmd.append("app_segment_clean[" + zoneCoordinates)
                            }
                            else
                            {
                                roomCmd.append(", " + zoneCoordinates)
                            }
                        }

                        logDebug("zone.rules", roomCmd.toString)
                    }
                ]
            }
        ]
    ]

    // if we have rooms AND zones, rooms wins - duplicate code here as well
    if (roomCmd.length != 0)
    {
        val cmd = roomCmd.toString + "]"
        logInfo("zone.rules", "sending cmd to device: " + cmd )
        XiaVac_action_Command.sendCommand(cmd)
    }
    else if (zoneCmd.length != 0)
    {
        val cmd = zoneCmd.toString + "]"
        logInfo("zone.rules", "sending cmd to device: " + cmd )
        XiaVac_action_Command.sendCommand(cmd)
    }
    else
    {
        logInfo("zone.rules", "no zone or room selected. nothing to do.")
    }

    zoneAction.postUpdate("start")

end

// ----------------------------------------------------------------------------
rule "zone control - init"
// ----------------------------------------------------------------------------
when
    System started
then
    val lastUpdate = now

    gZoneLastUpdate.members.forEach(item | 
        item.postUpdate(lastUpdate.toString())
    )
end

Error in Log:

==> /logs/openhab.log <==

2022-02-16 09:08:17.325 [INFO ] [openhab.core.model.script.zone.rules] - update received from item: zKueche (Type=SwitchItem, State=ON, Label=Küche, Category=kitchen, Groups=[gKueche, gZoneSwitch, gAllZones])

2022-02-16 09:08:17.334 [INFO ] [openhab.core.model.script.zone.rules] - posting update to zEsszimmerLastUpdate

2022-02-16 09:08:17.403 [WARN ] [b.core.model.script.actions.BusEvent] - Cannot convert '2022-02-16T09:08:17.327743+01:00[Europe/Berlin]' to a state type which item 'zEsszimmerLastUpdate' accepts: [DateTimeType, UnDefType].

2022-02-16 09:08:17.408 [INFO ] [openhab.core.model.script.zone.rules] - posting update to zWohnzimmerLastUpdate

2022-02-16 09:08:17.411 [WARN ] [b.core.model.script.actions.BusEvent] - Cannot convert '2022-02-16T09:08:17.327743+01:00[Europe/Berlin]' to a state type which item 'zWohnzimmerLastUpdate' accepts: [DateTimeType, UnDefType].
==> /logs/openhab.log <==

2022-02-16 10:39:32.127 [INFO ] [openhab.core.model.script.zone.rules] - zoneAction command received: start

2022-02-16 10:39:32.130 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'robo-2' failed: Could not cast NULL to org.openhab.core.library.types.DateTimeType; line 55, column 37, length 21 in robo


Could anyone help me out ?

Thanks

Use new DateTimeType() instead of lastUpdate.toString

so l delete :

val lastUpdate = now

and change this :
updateItem.postUpdate(lastUpdate.toString())

to

updateItem.postUpdate(new DateTimeType()) ?

ok looks better with the time thing but still errors at all

2022-02-16 11:54:49.212 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'zKueche' received command ON

2022-02-16 11:54:49.213 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'zKueche' changed from OFF to ON

2022-02-16 11:54:49.218 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'zKuecheLastUpdate' changed from 2022-02-16T11:54:48.169828+0100 to 2022-02-16T11:54:49.216679+0100

2022-02-16 11:54:49.219 [INFO ] [hab.event.GroupItemStateChangedEvent] - Item 'gZoneLastUpdate' changed from 2022-02-16T11:54:48.183601+0100 to 2022-02-16T11:54:49.216679+0100 through zKuecheLastUpdate

==> /logs/openhab.log <==

2022-02-16 11:54:50.485 [INFO ] [openhab.core.model.script.zone.rules] - zoneAction command received: start

2022-02-16 11:54:50.502 [INFO ] [openhab.core.model.script.zone.rules] - 17-zEsszimmer is ON. {zoneType:room; zoneCoordinates: 17}

2022-02-16 11:54:50.522 [INFO ] [openhab.core.model.script.zone.rules] - 20-zKueche is ON. {zoneType:room; zoneCoordinates: 20}

2022-02-16 11:54:50.526 [INFO ] [openhab.core.model.script.zone.rules] - sending cmd to device: app_segment_clean[17, 20]

2022-02-16 11:54:50.527 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'robo-2' failed: The name 'actionCommand' cannot be resolved to an item or type; line 118, column 9, length 13 in robo


there is no word actionCommand in the rules above, so you must have changed other code accidentally.
just scroll to line 118 and check spelling of XiaVac_action_Command

Don’t forget to do something similar in rule “zone control - init”