Java Runtime Environment: openjdk version “1.8.0_152”
openHAB version: [master]v1.4.1-433(ee99445)
Issue of the topic: Good morning and sorry for my poor english. Ive looked for an answer without luck. Here is my problem…ive a web relay and i can query it with url http://192.168.1.6/status.xml i can see this:
When i activate a light, the btnX go to “dn” state…
Now, for example, i’ve a light called “Luce dell’ingresso” that is activate via manual button also…how can i update the status (icon and state) of this light (btn6) in OH and BasicUI when it change from a normal fisical button?
This is my .sitemap
rule "PT Luce Ingresso transform"
when
Item PT_Luce_Ingresso_String changed
then
if ( PT_Luce_Ingresso_String.state == UNDEF !! PT_Luce_Ingresso_String.state == NULL) return;
PT_Luce_Ingresso.postUpdate(transform("MAP", "onoff.map", PT_Luce_Ingresso_String.state.toString)
end
Many thanks for the reply…ive write your code in my OH and return this error
2018-12-26 22:02:24.353 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'default.rules' has errors, therefore ignoring it: [3,5]: no viable alternative at input 'PT_Luce_Ingresso_String'[5,49]: missing ')' at '!'[5,90]: mismatched input ')' expecting 'end'
In the onoff.map ive wrote
ON=dn
OFF=up
dn=ON
up=OFF
And in http.cfg
# configuration of the first cache item
Domo2.url=http://192.168.1.6/status.xml
Domo2.updateInterval=3000
rule "PT Luce Ingresso transform"
when
Item PT_Luce_Ingresso_String changed
then
if (PT_Luce_Ingresso_String.state == UNDEF || PT_Luce_Ingresso_String.state == NULL) return;
PT_Luce_Ingresso.postUpdate(transform("MAP", "onoff.map", PT_Luce_Ingresso_String.state.toString))
end
Ok ive typed all…there is a missing ) before the end statement…
but, ive this WARN…so is only a warn but i wanto to understand…THANK YOU VERY MUCH!
2018-12-26 22:17:44.004 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'default.rules' has errors, therefore ignoring it: [3,2]: no viable alternative at input 'PT_Luce_Ingresso_String'
Yes…after mod the light dont activate anymore.
I use “Google home” too…the “Switchable” must be in String?
Now my rules is
rule "PT Luce Ingresso transform"
when
PT_Luce_Ingresso_String changed
then
if (PT_Luce_Ingresso_String.state == UNDEF || PT_Luce_Ingresso_String.state == NULL) return;
PT_Luce_Ingresso.postUpdate(transform("MAP","onoff.map",PT_Luce_Ingresso_String.state.toString))
end
rule "LUCE INGRESSO ON"
when
Item PT_Luce_Ingresso received command ON
then
sendHttpGetRequest("http://192.168.1.2:8083/command=set_active?605")
end
rule "LUCE INGRESSO OFF"
when
Item PT_Luce_Ingresso received command OFF
then
sendHttpGetRequest("http://192.168.1.2:8083/command=set_deactive?605")
end
The LOG is (truncated) [why the sistem doesnt recognize change of state? the String change only this time]
2018-12-26 22:33:22.436 [vent.ItemStateChangedEvent] - PT_Luce_Ingresso_String changed from NULL to up
2018-12-26 22:33:25.660 [ome.event.ItemCommandEvent] - Item 'PT_Luce_Ingresso' received command ON
2018-12-26 22:33:25.682 [vent.ItemStateChangedEvent] - PT_Luce_Ingresso changed from NULL to ON
2018-12-26 22:33:28.441 [ome.event.ItemCommandEvent] - Item 'PT_Luce_Ingresso' received command OFF
2018-12-26 22:33:28.457 [vent.ItemStateChangedEvent] - PT_Luce_Ingresso changed from ON to OFF
Nothing to do…ive tried some change but nothing…cant understand
Ty a lot for your patience
UPDATE…NOW if i activate and deactivate the light from button the LOG write
2018-12-26 22:59:11.204 [vent.ItemStateChangedEvent] - PT_Luce_Ingresso_String changed from up to dn
2018-12-26 22:59:20.405 [vent.ItemStateChangedEvent] - PT_Luce_Ingresso_String changed from dn to up
BEATIFUL…but now why the button on sitemap doesnt activate?
Seems that the rule “LUCE INGRESSO ON” received command but dont execute the “then”
rule "PT Luce Ingresso transform"
when
PT_Luce_Ingresso_String changed
then
if (PT_Luce_Ingresso_String.state == UNDEF || PT_Luce_Ingresso_String.state == NULL) return;
PT_Luce_Ingresso.sendCommand(transform("MAP","onoff.map",PT_Luce_Ingresso_String.state.toString))
end
rule "LUCE INGRESSO ON"
when
Item PT_Luce_Ingresso received command ON
then
sendHttpGetRequest("http://192.168.1.2:8083/command=set_active?605")
end
The LOG
2018-12-26 23:09:19.443 [ome.event.ItemCommandEvent] - Item 'PT_Luce_Ingresso' received command ON
2018-12-26 23:09:19.459 [vent.ItemStateChangedEvent] - PT_Luce_Ingresso changed from OFF to ON
rule "LUCE INGRESSO ON"
when
Item PT_Luce_Ingresso received command ON
then
sendHttpGetRequest("http://192.168.1.2:8083/command=set_active?605")
end
rule "PT Luce Ingresso transform"
when
Item PT_Luce_Ingresso_String changed
then
if (PT_Luce_Ingresso_String.state == UNDEF || PT_Luce_Ingresso_String.state == NULL) return;
PT_Luce_Ingresso.sendCommand(transform("MAP","onoff.map",PT_Luce_Ingresso_String.state.toString))
end