Simple zoneminder motion rule with timer

Im trying to setup a motion dect (via Zoneminder) to trigger a light. I see messages in the log file where the motion is toggling ON/ OFF, however, my newbie script is not turning on a light. Any help appreciated! THX.

Rules:
var Integer counter_patio_light = 0

rule "Motion Light ON Patio"
when
Item Patio_motion changed from OFF to ON
then
if (NightState.state = ON){
sendCommand(Gold_lamp, ON)
counter_patio_light = 2
}
end

rule "every minute"
when
Time cron "0 * * * * ?"
then
if (counter_patio_light > 0) counter_patio_light = counter_patio_light - 1
if (counter_patio_light == 1) sendCommand(Gold_lamp, OFF)
end

items:
Switch Patio_motion “switch” {channel=“zoneminder:monitor:94da2af1:monitor-2:alarm”}

Logfile:

[vent.ItemStateChangedEvent] - zoneminder_monitor_94da2af1_monitor_2_force_alarm changed from OFF to ON

[vent.ItemStateChangedEvent] - zoneminder_monitor_94da2af1_monitor_2_alarm changed from OFF to ON

First thing, please always use code fences to post code, as discourse software will change some characters and the code is more readable as well.
```

Your code goes here

```
You accidentally used = instead of ==:

var Integer counter_patio_light = 0

rule "Motion Light ON Patio"
when
    Item Patio_motion changed from OFF to ON
then
    if (NightState.state == ON) { // use == here
        // sendCommand(Gold_lamp, ON)
        Gold_lamp.sendCommand(ON)  //both should work, but the method should be preferred
        counter_patio_light = 2
    }
end

rule "every minute"
when
    Time cron "0 * * * * ?"
then
    if (counter_patio_light > 0)
       counter_patio_light = counter_patio_light - 1
    if (counter_patio_light == 1)
       Gold_lamp.sendCommand(OFF)
end

Thank you, looks like its working!
_