Astro trigger fires rule more than once per day

Hello,

I’m using rules with the triggers ‘civilDuskEnd’ and ‘civilDawnEnd’ from the astro binding to close and open the blinds. Both rules are similar to the event example rule of the binding. That’s working very good. The only annoying thing is that both rules keep sending the up/down command. My understanding was, that a trigger is only fired once and so the rule is only executed one single time per day!?

Kind regards,
Dirk

Could you post the aforementioned rules, please?
Don’t forget the code fences, thanks.

rule 'Rolladen Morgens hoch'
when
      Channel "astro:sun:local:civilDawn#event" triggered END
then
        logInfo("astro logging", "Rolladen Morgens hoch")

        shutter1.sendCommand(UP)
        shutter2.sendCommand(UP)
        shutter3.sendCommand(UP)
        shutter4.sendCommand(UP)
end

Can you show the log showing the event and the execution of the rule, please?

Ok…: according to the log, the rule is only executed once but the gateway of the blinds is receiving the MQTT commands again and again. Now I’m busy with searching the mosquitto.log. Maybe it’s an issue with the handshake between the gateway and the mosquitto server. Openhab seems not to be the problem as I stated in my 1st post.

2018-10-09 07:50:00.009 [vent.ChannelTriggeredEvent] - astro:sun:local:rise#event triggered START

==> /var/log/openhab2/openhab.log <==

2018-10-09 07:50:00.016 [INFO ] [smarthome.model.script.astro logging] - Rolladen Morgens hoch

==> /var/log/openhab2/events.log <==

2018-10-09 07:50:00.029 [ome.event.ItemCommandEvent] - Item 'shutter1' received command UP

2018-10-09 07:50:00.039 [ome.event.ItemCommandEvent] - Item 'shutter2' received command UP

2018-10-09 07:50:00.045 [vent.ItemStateChangedEvent] - shutter1 changed from 100 to 0

2018-10-09 07:50:00.058 [ome.event.ItemCommandEvent] - Item 'shutter3' received command UP

2018-10-09 07:50:00.065 [ome.event.ItemCommandEvent] - Item 'shutter4' received command UP

2018-10-09 07:50:00.070 [vent.ItemStateChangedEvent] - shutter2 changed from 100 to 0

2018-10-09 07:50:00.080 [vent.ItemStateChangedEvent] - shutter3 changed from 100 to 0

2018-10-09 07:50:00.083 [vent.ItemStateChangedEvent] - shutter4 changed from 100 to 0

Ok, this is due to the nature in the rollershuter item
send the command 0 directly instead of UP
I think 0 is UP and 100 is down but it could be the other way around, not sure:

rule 'Rolladen Morgens hoch'
when
      Channel "astro:sun:local:civilDawn#event" triggered END
then
        logInfo("astro logging", "Rolladen Morgens hoch")

        shutter1.sendCommand(0)
        shutter2.sendCommand(0)
        shutter3.sendCommand(0)
        shutter4.sendCommand(0)
end

Indeed: answer and command are not matching so it could be that the command is sent again and again.
Good tip, I’ll try and give feedback

Unfortunately not :frowning: the following lines show the log of the receiving gateway:

2018-10-09 13:19:08 CEST [INFO] - incoming MQTT command: channel 3: 0
2018-10-09 13:19:08 CEST [INFO] - command UP for channel 3 (Terrassenfenster) sent.
2018-10-09 13:26:44 CEST [INFO] - trying to connect to MQTT broker
2018-10-09 13:26:44 CEST [INFO] - MQTT connect success
2018-10-09 13:26:44 CEST [INFO] - incoming MQTT command: channel 0: 0
2018-10-09 13:26:45 CEST [INFO] - command UP for channel 0 (Kueche) sent.
2018-10-09 13:26:45 CEST [INFO] - incoming MQTT command: channel 1: 0
2018-10-09 13:26:45 CEST [INFO] - command UP for channel 1 (Wohnzimmer) sent.
2018-10-09 13:26:46 CEST [INFO] - incoming MQTT command: channel 2: 0
2018-10-09 13:26:46 CEST [INFO] - command UP for channel 2 (Terrassentuer) sent.
2018-10-09 13:26:46 CEST [INFO] - incoming MQTT command: channel 3: 0
2018-10-09 13:26:47 CEST [INFO] - command UP for channel 3 (Terrassenfenster) sent.
2018-10-09 13:32:38 CEST [INFO] - trying to connect to MQTT broker
2018-10-09 13:32:38 CEST [INFO] - MQTT connect success
2018-10-09 13:32:42 CEST [INFO] - incoming MQTT command: channel 0: 0
2018-10-09 13:32:42 CEST [INFO] - command UP for channel 0 (Kueche) sent.
2018-10-09 13:32:42 CEST [INFO] - incoming MQTT command: channel 1: 0
2018-10-09 13:32:43 CEST [INFO] - command UP for channel 1 (Wohnzimmer) sent.
2018-10-09 13:32:43 CEST [INFO] - incoming MQTT command: channel 2: 0
2018-10-09 13:32:43 CEST [INFO] - command UP for channel 2 (Terrassentuer) sent.
2018-10-09 13:32:44 CEST [INFO] - incoming MQTT command: channel 3: 0
2018-10-09 13:32:44 CEST [INFO] - command UP for channel 3 (Terrassenfenster) sent.
2018-10-09 13:33:50 CEST [INFO] - trying to connect to MQTT broker
2018-10-09 13:33:50 CEST [INFO] - MQTT connect success
2018-10-09 13:33:50 CEST [INFO] - incoming MQTT command: channel 0: 0
2018-10-09 13:33:51 CEST [INFO] - command UP for channel 0 (Kueche) sent.
2018-10-09 13:33:51 CEST [INFO] - incoming MQTT command: channel 1: 0
2018-10-09 13:33:51 CEST [INFO] - command UP for channel 1 (Wohnzimmer) sent.
2018-10-09 13:33:52 CEST [INFO] - incoming MQTT command: channel 2: 0
2018-10-09 13:33:52 CEST [INFO] - command UP for channel 2 (Terrassentuer) sent.
2018-10-09 13:33:52 CEST [INFO] - incoming MQTT command: channel 3: 0
2018-10-09 13:33:53 CEST [INFO] - command UP for channel 3 (Terrassenfenster) sent.
2018-10-09 13:39:59 CEST [INFO] - trying to connect to MQTT broker
2018-10-09 13:39:59 CEST [INFO] - MQTT connect success
2018-10-09 13:39:59 CEST [INFO] - incoming MQTT command: channel 0: 0
2018-10-09 13:40:00 CEST [INFO] - command UP for channel 0 (Kueche) sent.
2018-10-09 13:40:00 CEST [INFO] - incoming MQTT command: channel 1: 0
2018-10-09 13:40:00 CEST [INFO] - command UP for channel 1 (Wohnzimmer) sent.
2018-10-09 13:40:00 CEST [INFO] - incoming MQTT command: channel 2: 0
2018-10-09 13:40:01 CEST [INFO] - command UP for channel 2 (Terrassentuer) sent.
2018-10-09 13:40:01 CEST [INFO] - incoming MQTT command: channel 3: 0
2018-10-09 13:40:01 CEST [INFO] - command UP for channel 3 (Terrassenfenster) sent.

could this be the problem (timeout/disconnection). Attached is a part of the Mosquitto.log:

1539084831: Client JaroliftDongle-0003f43d has exceeded timeout, disconnecting.
1539084831: New connection from 192.168.178.35 on port 1883.
1539084831: New client connected from 192.168.178.35 as JaroliftDongle-0003f43d (c1, k15, u).
1539084831: Sending CONNACK to JaroliftDongle-0003f43d (0)
1539084831: Received SUBSCRIBE from JaroliftDongle-0003f43d
1539084831: 	cmd/jarolift/# (QoS 0)
1539084831: JaroliftDongle-0003f43d 0 cmd/jarolift/#
1539084831: Sending SUBACK to JaroliftDongle-0003f43d
1539084831: Sending PUBLISH to JaroliftDongle-0003f43d (d0, q0, r1, m0, 'cmd/jarolift/shutter/0', ... (1 bytes))
1539084831: Sending PUBLISH to JaroliftDongle-0003f43d (d0, q0, r1, m0, 'cmd/jarolift/shutter/1', ... (1 bytes))
1539084831: Sending PUBLISH to JaroliftDongle-0003f43d (d0, q0, r1, m0, 'cmd/jarolift/shutter/2', ... (1 bytes))
1539084831: Sending PUBLISH to JaroliftDongle-0003f43d (d0, q0, r1, m0, 'cmd/jarolift/shutter/3', ... (1 bytes))
1539084831: Received PUBLISH from JaroliftDongle-0003f43d (d0, q0, r1, m0, 'tele/jarolift/LWT', ... (6 bytes))
1539084832: Received PUBLISH from JaroliftDongle-0003f43d (d0, q0, r0, m0, 'stat/jarolift/shutter/0', ... (1 bytes))
1539084832: Sending PUBLISH to OpenHAB2 (d0, q0, r0, m0, 'stat/jarolift/shutter/0', ... (1 bytes))
1539084832: Received PUBLISH from JaroliftDongle-0003f43d (d0, q0, r1, m0, 'stat/jarolift/devicecounter', ... (4 bytes))
1539084832: Received PUBLISH from JaroliftDongle-0003f43d (d0, q0, r0, m0, 'stat/jarolift/shutter/1', ... (1 bytes))
1539084832: Sending PUBLISH to OpenHAB2 (d0, q0, r0, m0, 'stat/jarolift/shutter/1', ... (1 bytes))
1539084832: Received PUBLISH from JaroliftDongle-0003f43d (d0, q0, r1, m0, 'stat/jarolift/devicecounter', ... (4 bytes))
1539084833: Received PUBLISH from JaroliftDongle-0003f43d (d0, q0, r0, m0, 'stat/jarolift/shutter/2', ... (1 bytes))
1539084833: Sending PUBLISH to OpenHAB2 (d0, q0, r0, m0, 'stat/jarolift/shutter/2', ... (1 bytes))
1539084833: Received PUBLISH from JaroliftDongle-0003f43d (d0, q0, r1, m0, 'stat/jarolift/devicecounter', ... (4 bytes))
1539084834: Received PUBLISH from JaroliftDongle-0003f43d (d0, q0, r0, m0, 'stat/jarolift/shutter/3', ... (1 bytes))
1539084834: Sending PUBLISH to OpenHAB2 (d0, q0, r0, m0, 'stat/jarolift/shutter/3', ... (1 bytes))
1539084834: Received PUBLISH from JaroliftDongle-0003f43d (d0, q0, r1, m0, 'stat/jarolift/devicecounter', ... (4 bytes))
1539084849: Received PINGREQ from JaroliftDongle-0003f43d
1539084849: Sending PINGRESP to JaroliftDongle-0003f43d
1539084863: Received PINGREQ from JaroliftDongle-0003f43d

Your gateway keeps trying to connect to the broker and when it succeeds it receives this data.
Do you have persist enabled on your MQTT broker by any chance?
Because everytime the gateway reconnect it will receive the last command sent to it by default.

I already read somewhere about the ‘persist enabled’ but I could not figure out where I have to configure it? Do I have to configure it in the mqtt.cfg (openhab2) or mosquitto.conf?

That can be done in both
Can you publish both, please?

MQTT.CFG:

# Define your MQTT broker connections here for use in the MQTT Binding or MQTT
# Persistence bundles. Replace <broker> with an ID you choose.
#

# URL to the MQTT broker, e.g. tcp://localhost:1883 or ssl://localhost:8883
mosquitto.url=tcp://localhost:1883

# Optional. Client id (max 23 chars) to use when connecting to the broker.
# If not provided a random default is generated.
mosquitto.clientId=OpenHAB2

# Optional. True or false. If set to true, allows the use of clientId values
# up to 65535 characters long. Defaults to false.
# NOTE: clientId values longer than 23 characters may not be supported by all
# MQTT servers. Check the server documentation.
mosquitto.allowLongerClientIds=false

# Optional. User id to authenticate with the broker.
#mosquitto.user=<user>

# Optional. Password to authenticate with the broker.
#mosquitto.pwd=<password>

# Optional. Set the quality of service level for sending messages to this broker.
# Possible values are 0 (Deliver at most once),1 (Deliver at least once) or 2
# (Deliver exactly once). Defaults to 0.
mosquitto.qos=1

# Optional. True or false. Defines if the broker should retain the messages sent to
# it. Defaults to false.
mosquitto.retain=true

# Optional. True or false. Defines if messages are published asynchronously or
# synchronously. Defaults to true.
mosquitto.async=false

# Optional. Defines the last will and testament that is sent when this client goes offline
# Format: topic:message:qos:retained <br/>
#mosquitto.lwt=<last will definition>

mosquitto.conf:

# Place your local configuration in /etc/mosquitto/conf.d/
#
# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.example

pid_file /var/run/mosquitto.pid

persistence true
persistence_location /var/lib/mosquitto/

log_dest file /var/log/mosquitto/mosquitto.log
log_type all

include_dir /etc/mosquitto/conf.d

and a mqtt.config???:

mosquitto.allowLongerClientIds="false"
mosquitto.async="false"
mosquitto.clientId="OpenHAB2"
mosquitto.qos="1"
mosquitto.retain="true"
mosquitto.url="tcp://localhost:1883"
mosquitto.async="false"
service.pid="org.openhab.mqtt"

Ok,
In the mqtt.cfg change to:

mosquitto.retain=false

in the mosquitto.conf change to:
persistence false

Then reboot

The mqtt.config get generated by OH from the mqtt.cfg
You don’t need to change that

Great, those changes did the trick. Thank you very much!!!