Rule or script to detect states

Everything works fine less when I control from MQTTfx or from the device I do not get un update, only that.

Items sitemaps works fine. Mosquitto works fine. But it seems that there is no link between broker and OH2 client.

I regret that the log does not work properly, I tried to load the log page and I get en error, and I have also tried with http://openhabianpi.local:9001/, without sucess. :confused:

Have you installed frontail to show the log on this way?

yes, from openhabian-config

ok, I have reinstalled frontail, now log is working under server.local.9001, this is the log. I do not use authentification.

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

2018-04-04 11:07:37.490 [INFO ] [.dashboard.internal.DashboardService] - Started dashboard at http://192.168.2.123:8080

2018-04-04 11:07:37.522 [INFO ] [.dashboard.internal.DashboardService] - Started dashboard at https://192.168.2.123:8443

2018-04-04 11:07:37.565 [INFO ] [io.openhabcloud.internal.CloudClient] - Connected to the openHAB Cloud service (UUID = 380913da-73ab-47c2-b409-d9de603a82c0, base URL = http://localhost:8080)

2018-04-04 11:07:53.789 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'home.items'

2018-04-04 11:07:59.479 [INFO ] [arthome.ui.paper.internal.PaperUIApp] - Started Paper UI at /paperui

2018-04-04 11:07:59.655 [WARN ] [penhab.io.transport.mqtt.MqttService] - Unrecognized property: mosquitto.usr

2018-04-04 11:07:59.659 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.

2018-04-04 11:07:59.661 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'mosquitto'

2018-04-04 11:08:00.167 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'broker'

2018-04-04 11:08:00.498 [INFO ] [basic.internal.servlet.WebAppServlet] - Started Basic UI at /basicui/app

2018-04-04 11:08:03.164 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'home.rules'

2018-04-04 11:08:03.435 [INFO ] [thome.model.lsp.internal.ModelServer] - Started Language Server Protocol (LSP) service on port 5007

2018-04-04 11:08:04.130 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'home.sitemap'

2018-04-04 11:08:04.709 [INFO ] [ui.habmin.internal.servlet.HABminApp] - Started HABmin servlet at /habmin

2018-04-04 11:08:04.940 [INFO ] [panel.internal.HABPanelDashboardTile] - Started HABPanel at /habpanel

2018-04-04 11:08:05.664 [INFO ] [assic.internal.servlet.WebAppServlet] - Started Classic UI at /classicui/app

But sending from OH works?

Please use code fences for the log. Use the buttons above the textfield!

```   
your code goes here
```

I think you have a problem with you installation.
Without knowing what you have done it is painful to asking all details.
There are different raspian-versions.

I would start with a new installation unsing this way https://docs.openhab.org/installation/openhabian.html
and Raspberry Pi image v1.4.1 openHABian v1.4 released!

sorry.
yes from OH works fine.

Yes, I will try a new clean installation.
This is not working properly, at least the link between mosquitto and OH.

I will try v.1.4.1

Thanks.

Why do you have 2 mqtt-broker connections?

Please post the commands MQTTfx show.

good question, what the hell is that? But, in mqtt.cfg file I only have mosuitto.url. why the system tries to start other broker?

FYI: I had a openhabian version from 17.12. 2017. I am going to reinstll everything.

MQTTfx commands are:

cmnd/sonoff01/POWER PAYLOAD: ON/OFF
stat/sonoff01/POWER

and from MQTTfx is working fine, I get commanded and publish.

try

<[mosquitto:stat/sonoff01/POWER:state:MAP(onoff.map)]", update="false"}

thanks hr_2

I will try after resintall everything.

Why don’t you try @hr_2 suggestion before reinstalling everything. The binding did work ( switching worked) only the feedback from the device wasn’t configured correctly.

ok, I will try but at night before reinstall, because I have to go to work :smiley:
thank you for your help!!

I have got some progress. After try what hr_2 posted, I do not get that OH get states updated.
I decided to reinstall everything. OH and Mosquitto are running ok, everythim I release a command from MQTTfx, I got a message in the OH log, and it seems that something in the onoff.map is wrong

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

2018-04-04 22:55:33.363 [INFO ] [.dashboard.internal.DashboardService] - Started dashboard at http://192.168.2.123:8080
2018-04-04 22:55:33.396 [INFO ] [.dashboard.internal.DashboardService] - Started dashboard at https://192.168.2.123:8443
2018-04-04 22:55:48.905 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'home.items'
2018-04-04 22:55:52.299 [INFO ] [thome.model.lsp.internal.ModelServer] - Started Language Server Protocol (LSP) service on port 5007
2018-04-04 22:55:55.349 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'home.rules'
2018-04-04 22:55:56.770 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'home_vis.sitemap'
2018-04-04 22:55:56.819 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'home.sitemap'
2018-04-04 22:55:58.815 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
2018-04-04 22:55:58.818 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'mosquitto'
2018-04-04 22:55:59.413 [INFO ] [basic.internal.servlet.WebAppServlet] - Started Basic UI at /basicui/app
2018-04-04 22:55:59.867 [INFO ] [assic.internal.servlet.WebAppServlet] - Started Classic UI at /classicui/app
2018-04-04 22:55:59.943 [INFO ] [arthome.ui.paper.internal.PaperUIApp] - Started Paper UI at /paperui
2018-04-04 22:56:00.101 [INFO ] [ui.habmin.internal.servlet.HABminApp] - Started HABmin servlet at /habmin
2018-04-04 22:56:00.581 [INFO ] [panel.internal.HABPanelDashboardTile] - Started HABPanel at /habpanel
2018-04-04 22:57:43.053 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'home.items'
2018-04-04 22:57:43.116 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'home.items'
2018-04-04 22:59:55.216 [ome.event.ItemCommandEvent] - Item 'sonoff04' received command ON
2018-04-04 22:59:55.281 [WARN ] [rm.AbstractFileTransformationService] - Could not transform 'ON' with the file 'onoff.map' : Target value not found in map for 'ON'
2018-04-04 22:59:55.284 [WARN ] [b.core.events.EventPublisherDelegate] - given new state is NULL, couldn't post update for 'sonoff04'

So, I had this in the onoff.map

0=OFF
1=ON

But it was not enough, SO, I decided to change them to:

OFF=OFF
ON=ON
NULL=OFF

AAANNNDD NOW IT IS WORKING!!! :smiley:

Thank you for your help!!

In this case you would not need a map transformation. As your commands are already on and off.

I thought about it, but what happend with NULL? I got a warning in the log… Well, I will try

Yeah NULL. But do you get NULL states?

Yes, I did get but I think only when I reboot and turn on/off switches first time, after one cycle of ON/OFF I do not get NULL states anymore, … that is why I wrote NULL in the onoff.map

2018-04-04 22:59:55.284 [WARN ] [b.core.events.EventPublisherDelegate] - given new state is NULL, couldn't post update for 'sonoff04'

I think this can be ignored then, but this is just my opinion.
Just on a gut level i would expect faster processing without map.