Openhab 2 + espeasy + relay can't control it (topic mqtt message problem ?)

  • Platform information:
    • Hardware: CPUArchitecture/RAM/storage
    • OS: Openhabian on Raspberry Pi3 B+_
    • openHAB version: 2

Hello all
I have problen with relay (I can’t control it) I add switch in espeasy but I cant make it work. below I add my config hope someone help me find solution.

in my router I see device name “czujkap-1” maybe I miss that number “1” ?





And I have a lot of this error:

2019-01-21 11:49:10.030 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'Set random image URLs': The name 'ImageURL' cannot be resolved to an item or type; line 138, column 16, length 8

2019-01-21 11:49:20.023 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'Set random wifi variations': The name 'Wifi_Level' cannot be resolved to an item or type; line 128, column 16, length 10

2019-01-21 11:49:20.030 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'Set random image URLs': The name 'ImageURL' cannot be resolved to an item or type; line 138, column 16, length 8

2019-01-21 11:49:30.031 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'Set random image URLs': The name 'ImageURL' cannot be resolved to an item or type; line 138, column 16, length 8

2019-01-21 11:49:40.023 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'Set random wifi variations': The name 'Wifi_Level' cannot be resolved to an item or type; line 128, column 16, length 10

2019-01-21 11:49:40.035 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'Set random image URLs': The name 'ImageURL' cannot be resolved to an item or type; line 138, column 16, length 8

2019-01-21 11:49:50.031 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'Set random image URLs': The name 'ImageURL' cannot be resolved to an item or type; line 138, column 16, length 8

2019-01-21 11:50:00.022 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'Set random room temperatures': The name 'Temperature' cannot be resolved to an item or type; line 96, column 5, length 11

2019-01-21 11:50:00.036 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'Set random image URLs': The name 'ImageURL' cannot be resolved to an item or type; line 138, column 16, length 8

2019-01-21 11:50:00.047 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'Set random wifi variations': The name 'Wifi_Level' cannot be resolved to an item or type; line 128, column 16, length 10

2019-01-21 11:50:10.028 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'Set random image URLs': The name 'ImageURL' cannot be resolved to an item or type; line 138, column 16, length 8

2019-01-21 11:50:20.023 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'Set random wifi variations': The name 'Wifi_Level' cannot be resolved to an item or type; line 128, column 16, length 10

2019-01-21 11:50:20.034 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'Set random image URLs': The name 'ImageURL' cannot be resolved to an item or type; line 138, column 16, length 8

2019-01-21 11:50:30.028 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'Set random image URLs': The name 'ImageURL' cannot be resolved to an item or type; line 138, column 16, length 8

There is an error in your rules, can you post it?

I don’t set any of this just generate sitemap using builder.

import java.util.Random

var Timer timer = null
val resList = newArrayList("640/480", "320/240", "480/360")
val urlList = newArrayList("https://www.fillmurray.com", "https://www.fillmurray.com/g",
                 "https://www.placecage.com", "https://www.placecage.com/c", "https://www.placecage.com/g")
val Random random = new Random()

/**
 * This is a demo rule which simulates a real dimmer by reacting to increase/decrease commands
 * and posting an updated state on the bus
 */
rule "Dimmed Light"
when
    Item DimmedLight received command
then
    if ((receivedCommand == INCREASE) || (receivedCommand == DECREASE)) {
        var Number percent = 0
        if (DimmedLight.state instanceof DecimalType) percent = DimmedLight.state as DecimalType

        if (receivedCommand == INCREASE) percent = percent + 5
        if (receivedCommand == DECREASE) percent = percent - 5

        if (percent < 0)   percent = 0
        if (percent > 100) percent = 100
        postUpdate(DimmedLight, percent);
    }
end

rule "Timer Demo"
when
    Item Light_GF_Corridor_Ceiling received command
then
    if (receivedCommand == ON) {
        if (timer === null) {
            // first ON command, so create a timer to turn the light off again
            timer = createTimer(now.plusSeconds(10)) [|
                sendCommand(Light_GF_Corridor_Ceiling, OFF)
            ]
        } else {
            // subsequent ON command, so reschedule the existing timer
            timer.reschedule(now.plusSeconds(10))
        }
    } else if (receivedCommand == OFF) {
        // remove any previously scheduled timer
        if (timer !== null) {
            timer.cancel
            timer = null
        }
    }
end

/**
 * The following rules help initializing the demo items with some helpful states.
 */
rule "Initialize light states"
when
    System started
then
    Lights?.members.forEach(light|
        postUpdate(light, if (Math::random > 0.7) ON else OFF)
    )
end

rule "Initialize heating states"
when
    System started
then
    Heating?.members.forEach(heating|
        postUpdate(heating, if (Math::random > 0.8) ON else OFF)
    )
    postUpdate(Temperature_Setpoint, 22)
end

rule "Initialize contact states"
when
    System started
then
    Windows?.members.forEach(window|
        postUpdate(window, if (Math::random > 0.5) OPEN else CLOSED)
    )
end

rule "Initialize Location"
when
    System started
then
    DemoLocation.postUpdate(new PointType("52.5200066,13.4049540"))
end

rule "Set random room temperatures"
when
    System started or
    Time cron "0 0/5 * * * ?"
then
    Temperature?.members.forEach(temperature|
        postUpdate(temperature, 20.0 + (25.0 - (Math::random * 50.0).intValue) / 10.0)
    )
end

rule "Set daily max and min temperature"
when
    Item Weather_Temperature changed or
    Time cron "0 0 0 * * ?" or
    System started
then
    val max = Weather_Temperature.maximumSince(now.withTimeAtStartOfDay)
    val min = Weather_Temperature.minimumSince(now.withTimeAtStartOfDay)
    if (max !== null && min !== null) {
        postUpdate(Weather_Temp_Max, max.state)
        postUpdate(Weather_Temp_Min, min.state)
    }
end

// Creates an item that stores the last update time of this item
rule "Records last weather update time"
when
    Item Weather_Temperature received update
then
    postUpdate(Weather_LastUpdate, new DateTimeType())
end

rule "Set random wifi variations"
when
    System started or
    Time cron "/20 * * * * ?"
then
    postUpdate(Wifi_Level, (Math::random * 4.0).intValue)
end

rule "Set random image URLs"
when
    Time cron "/10 * * * * ?"
then
    val url = urlList.get(random.nextInt(urlList.length))
    val res = resList.get(random.nextInt(resList.length))

    postUpdate(ImageURL, url + "/" + res)
end

rule "Volume"
when
    Item Volume received command
then
    if (receivedCommand instanceof PercentType) {
        setMasterVolume(receivedCommand)
    } else {
        if (receivedCommand == INCREASE) increaseMasterVolume(20)
        if (receivedCommand == DECREASE) decreaseMasterVolume(20)
    }
end

rule "Select Radio Station"
when
    Item Radio_Station received command
then
    switch(receivedCommand) {
        case 0 : playStream(null)
        case 1 : playStream("http://metafiles.gl-systemhaus.de/hr/hr3_2.m3u")
        case 2 : playStream("http://mp3-live.swr3.de/swr3_m.m3u")
    }
end

// vim: syntax=Xtend

Its not the problem right now more important for me to make work that nodemcu v3 with espeasy and relay.

I manage to get it work but…

I use:
MQTT Command: “/czujkap/gpio/12”
ON Command set to 1
OFF Command set to 0
When I turn switch on in paper ui OH relay turn on but When I switch to off relay stay ON (red light still on)
What is the proper way to read status of relay/switch I use now:
“/czujkap/gpio/12/state” But I’m sure its wrong can someone help me to get it work ?

rule "Set random image URLs"
when
    Time cron "/10 * * * * ?"
then
    val url = urlList.get(random.nextInt(urlList.length))
    val res = resList.get(random.nextInt(resList.length))

    postUpdate(ImageURL, url + "/" + res)
end

What is the item ImageURL ?

@vzorglub

I use openhabian end my rule file is stock/demo I don’t mess with it just use home builder plugin to build sitemap and modifi it.
Can You please look above and help me with that relay ?

after use command in browser:
http://192.168.1.6/control?cmd=status,GPIO,12
I get:
{
“log”: “”,
“plugin”: 1,
“pin”: 12,
“mode”: “output”,
“state”: 0
}

@Sadek
You posted an eror, I am trying to help you with that.
When that’s done, you can explain what you want to do with that relay

I just delete that rule becouse I don’t use it. I play with rules after I config sitemaps / items / switches hardware etc.
I don’t have “ImageURL” in items.