[SOLVED] Item State not updating

I have a problem. I only want my WakeUpLight to switch when it is OFF. I tried a few things to make this work but OpenHab keeps sending a ON command to my light. I have the feeling it is that the state of the item isn’t updating correctly.

My items:

Switch WakeUpLight "WakeUpLight" <light> ["switchable"]  {mqtt=">[broker:cmnd/WakeUpLight/POWER:command:ON:1], >[broker:cmnd/WakeUpLight/POWER:command:OFF:0],<[broker:stat/WakeUpLight/POWER1:state:default]", autoupdate="false"} 


DateTime Echo_Kamer_Gregory_NextAlarm "NextAlarm"  {channel = "amazonechocontrol:echo:cf45e806:echo1:nextAlarm"}
DateTime Date  "Date [%1$tA, %1$td.%1$tm.%1$tY %1$tH:%1$tM]"  { channel="ntp:ntp:demo:dateTime" }

My rule

import org.joda.time.*
import org.openhab.core.library.types.*


rule "Alexa Wake Up Light"
when
Time cron "0 * * ? * *"
then
if(Date.state != NULL && Echo_Kamer_Gregory_NextAlarm.state != NULL) {
    var DateTime Alarm = new DateTime((Echo_Kamer_Gregory_NextAlarm.state as DateTimeType).calendar.timeInMillis)
    var DateTime Current_Time = new DateTime((Date.state as DateTimeType).calendar.timeInMillis)
    if(Current_Time > Alarm.minusMinutes(30) && Current_Time < Alarm && WakeUpLight.getStateAs(OnOffType) != ON){
        WakeUpLight.sendCommand(ON)
    }
} 
end

When i check the logInfo with command

logInfo("TEST1", WakeUpLight.state.toString)

I get
2019-02-06 18:16:00.105 [INFO ] [eclipse.smarthome.model.script.TEST1] - NULL
everytime. No matter what the state from the switch is.

I found the solution.in my Items file I misprogrammed my WakeUpLight Switch Item.
I changed autoupdate =“false” tot autoupdate = “true”.

That’s not the real fix here. autoupdate just means that a command sent to the Item causes an automatic state update to the best guess openHAB makes.
It’s not the real state of the target device, for example if something else like a wall switch changes it, you will not know.

Your Item has an inbound MQTT binding <[…] which doesn’t appear to work the way you expect.

The inbound MQTT should be:
<[broker:stat/WakeUpLight/POWER:state:default]

Not
<[broker:stat/WakeUpLight/POWER1:state:default]

Thanks
I read over it a couple times. Everything is working like it should be now

You can put the autoupdate back to false now. Tasmota will update the state as soon as changed.

That’s what I did. Thanks for the help!