[SOLVED] Sonoff basic MQTT binding switch not updating

I have MQTT working great. I have the MQTT Binding installed.
I have the following switch in my items and sitemap which work perfect

Switch FrontDownlights "Front Downlights" [ "Switchable" ]{mqtt=">[broker:cmnd/SmartHouse/Utilities/FrontDownli/power:command:*:default],<[broker:stat/SmartHouse/Utilities/FrontDownli/power:state:*:default]"}

The problem is, if i turn the switch on and off using any other way other than openhab, the switch in openhab is not updating to reflect the state.

Im getting these as publishes from the sonoff basic when this happens.
topic = stat/SmartHouse/Utilities/FrontDownli/POWER
message = ON or OFF

Can anyone help with this minor issue

PS.
Im getting this warning in the log but i cant figure out what its for. I think it may have something to do with the switch state not updating

2018-06-01 20:35:04.658 [WARN ] [mon.registry.AbstractManagedProvider] - Could not update element with key _tags:FrontDownlights in ManagedMetadataProviderImpl, because it does not exists.

I have this in the sitemap file

Switch item=FrontDownlights label="Front Downlights" icon="light"

MQTT topics are case sensitive!
OH will need POWER in capitals
sonoffs with tasmota don’t because the tasmota firmware is set-up to accept both power and POWER as an input

Switch FrontDownlights "Front Downlights" [ "Switchable" ]{mqtt=">[broker:cmnd/SmartHouse/Utilities/FrontDownli/power:command:*:default],<[broker:stat/SmartHouse/Utilities/FrontDownli/POWER:state:*:default]"}

Changed to capitals. and I get this when turning it on and off using openhab in the log. Its repeating

2018-06-01 20:43:51.481 [ome.event.ItemCommandEvent] - Item 'FrontDownlights' received command OFF

2018-06-01 20:43:51.525 [vent.ItemStateChangedEvent] - FrontDownlights changed from ON to OFF

2018-06-01 20:43:51.528 [vent.ItemStateChangedEvent] - FrontDownlights changed from OFF to ON

2018-06-01 20:43:56.851 [ome.event.ItemCommandEvent] - Item 'FrontDownlights' received command OFF

2018-06-01 20:43:56.890 [vent.ItemStateChangedEvent] - FrontDownlights changed from ON to OFF

2018-06-01 20:43:56.894 [vent.ItemStateChangedEvent] - FrontDownlights changed from OFF to ON

Now i cant even turn it off. When using OH to turn the switch off, it reverts back to on

2018-06-01 20:47:12.784 [ome.event.ItemCommandEvent] - Item 'FrontDownlights' received command OFF

2018-06-01 20:47:12.818 [vent.ItemStateChangedEvent] - FrontDownlights changed from ON to OFF

2018-06-01 20:47:12.823 [vent.ItemStateChangedEvent] - FrontDownlights changed from OFF to ON

2018-06-01 20:47:15.005 [ome.event.ItemCommandEvent] - Item 'FrontDownlights' received command OFF

2018-06-01 20:47:15.027 [vent.ItemStateChangedEvent] - FrontDownlights changed from ON to OFF

2018-06-01 20:47:15.033 [vent.ItemStateChangedEvent] - FrontDownlights changed from OFF to ON

2018-06-01 20:47:16.134 [ome.event.ItemCommandEvent] - Item 'FrontDownlights' received command OFF

2018-06-01 20:47:16.154 [vent.ItemStateChangedEvent] - FrontDownlights changed from ON to OFF

2018-06-01 20:47:16.158 [vent.ItemStateChangedEvent] - FrontDownlights changed from OFF to ON

2018-06-01 20:47:21.485 [ome.event.ItemCommandEvent] - Item 'FrontDownlights' received command OFF

2018-06-01 20:47:21.510 [vent.ItemStateChangedEvent] - FrontDownlights changed from ON to OFF

2018-06-01 20:47:21.513 [vent.ItemStateChangedEvent] - FrontDownlights changed from OFF to ON
Switch FrontDownlights "Front Downlights" [ "Switchable" ]{mqtt=">[broker:cmnd/SmartHouse/Utilities/FrontDownli/power:command:*:default],<[broker:stat/SmartHouse/Utilities/FrontDownli/POWER:state:default]"}
1 Like

my bad on the constant switch, I was trying to set a rule.
Your switch works great too. Im not sure what was happening but it was probably my bloody rule that i had trying to update the state, and forgot that i had it in there.
Thanks again

Use the last post
There was an error in the inbound binding parameters

Please like and mark the thread as solved. Thanks

One last question.
With the warning

2018-06-01 20:58:16.455 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'home.items'

2018-06-01 20:58:16.490 [WARN ] [mon.registry.AbstractManagedProvider] - Could not update element with key _tags:FrontDownlights in ManagedMetadataProviderImpl, because it does not exists.

is that just because nothing has been posted from the MQTT Server saying what state the switch is actually in?

No, that’s to do with the tag

Let’s tidy up a bit:

Switch FrontDownlights "Front Downlights" [ "Switchable" ] { mqtt=">[broker:cmnd/SmartHouse/Utilities/FrontDownli/power:command:*:default],<[broker:stat/SmartHouse/Utilities/FrontDownli/POWER:state:default]" }

That got rid of the error
so basically spaces after each

}

and before each

{ 

and spaces between

ble" ] { mqt

Is that just a layout thing?

The item definitions are read by a parser that will then distribute the different attributes to the OH engine. The parser can be a bit finicky at times. Better be careful and consistent. Most of the time it will work but sometimes the parser gets a bit stuck because of a missing space or something.
I would recommend that you revisit your item files and make sure you stick the something that works. Like this last one. Consistency is the key.

Good luck

Thanks for that. Withou starting a new thread, any idea why im only getting the first downlights device in google home when i sync devices. I used to get the garage and sprinklers also.

Switch FrontDownlights "Front Downlights" [ "Switchable" ] { mqtt=">[broker:cmnd/SmartHouse/Utilities/FrontDownli/power:command:*:default],<[broker:stat/SmartHouse/Utilities/FrontDownli/POWER:state:default]" }
Switch SprinklerSystemZone1 "Front Grass Sprinklers" [ "Switchable" ] { mqtt=">[broker:SmartHouse/Utilities/SprinklerSystem:command:ON:Z1ON],>[broker:SmartHouse/Utilities/SprinklerSystem:command:OFF:Z1OFF]" }
Switch SprinklerSystemZone2 "Front Garden Sprinklers" [ "Switchable" ] { mqtt=">[broker:SmartHouse/Utilities/SprinklerSystem:command:ON:Z2ON],>[broker:SmartHouse/Utilities/SprinklerSystem:command:OFF:Z2OFF]" }
Switch SprinklerSystemZone3 "Back Grass Sprinklers" [ "Switchable" ] { mqtt=">[broker:SmartHouse/Utilities/SprinklerSystem:command:ON:Z3ON],>[broker:SmartHouse/Utilities/SprinklerSystem:command:OFF:Z3OFF]" }
Switch SprinklerSystemZone4 "Back Garden Sprinklers" [ "Switchable" ] { mqtt=">[broker:SmartHouse/Utilities/SprinklerSystem:command:ON:Z4ON],>[broker:SmartHouse/Utilities/SprinklerSystem:command:OFF:Z4OFF]" }
Switch GarageDoor "Garage Door" [ "Switchable" ] {mqtt=">[broker:SmartHouse/Utilities/GarageDoor:command:ON:OPEN],>[broker:SmartHouse/Utilities/GarageDoor:command:OFF:CLOSE]"}

Nope
What does the log say when you refresh the items file?

theres in issue in the file i think. if i use putty to access it, it shows words green that shouldn’t be. has something to do with the mqtt command that we have in there.

as soon as i put the outbound symbol. it turns most of Switch Item names green.

Removing the front downlights fixes the google integration, Need to find out why its playing around with the formatting.

You may have a rogue invisible character in there
Comment out the line
and TYPE a new one

From what i can gather. the inbound rule must come before the outbound rule otherwise it turns the rest of the items into gibberish, but they still work.

The issue i have not once that is fixed is i get a warning for every item now.

2018-06-01 22:06:18.498 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'home.items'

2018-06-01 22:06:18.541 [WARN ] [mon.registry.AbstractManagedProvider] - Could not update element with key _tags:FrontDownlights in ManagedMetadataProviderImpl, because it does not exists.

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

2018-06-01 22:06:18.545 [ome.event.ItemUpdatedEvent] - Item 'FrontDownlights' has been updated.

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

2018-06-01 22:06:18.548 [WARN ] [mon.registry.AbstractManagedProvider] - Could not update element with key _tags:SprinklerSystemZone1 in ManagedMetadataProviderImpl, because it does not exists.

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

2018-06-01 22:06:18.554 [ome.event.ItemUpdatedEvent] - Item 'SprinklerSystemZone1' has been updated.

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

2018-06-01 22:06:18.556 [WARN ] [mon.registry.AbstractManagedProvider] - Could not update element with key _tags:SprinklerSystemZone2 in ManagedMetadataProviderImpl, because it does not exists.

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

2018-06-01 22:06:18.562 [ome.event.ItemUpdatedEvent] - Item 'SprinklerSystemZone2' has been updated.

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

2018-06-01 22:06:18.565 [WARN ] [mon.registry.AbstractManagedProvider] - Could not update element with key _tags:SprinklerSystemZone3 in ManagedMetadataProviderImpl, because it does not exists.

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

2018-06-01 22:06:18.570 [ome.event.ItemUpdatedEvent] - Item 'SprinklerSystemZone3' has been updated.

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

2018-06-01 22:06:18.573 [WARN ] [mon.registry.AbstractManagedProvider] - Could not update element with key _tags:SprinklerSystemZone4 in ManagedMetadataProviderImpl, because it does not exists.

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

2018-06-01 22:06:18.578 [ome.event.ItemUpdatedEvent] - Item 'SprinklerSystemZone4' has been updated.

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

2018-06-01 22:06:18.581 [WARN ] [mon.registry.AbstractManagedProvider] - Could not update element with key _tags:GarageDoor in ManagedMetadataProviderImpl, because it does not exists.

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

2018-06-01 22:06:18.586 [ome.event.ItemUpdatedEvent] - Item 'GarageDoor' has been updated.

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

2018-06-01 22:06:18.599 [WARN ] [mon.registry.AbstractManagedProvider] - Could not update element with key _tags:g_onHours1 in ManagedMetadataProviderImpl, because it does not exists.

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

2018-06-01 22:06:18.604 [ome.event.ItemUpdatedEvent] - Item 'g_onHours1' has been updated.

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

2018-06-01 22:06:18.606 [WARN ] [mon.registry.AbstractManagedProvider] - Could not update element with key _tags:onHours1_Mode in ManagedMetadataProviderImpl, because it does not exists.

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

2018-06-01 22:06:18.610 [ome.event.ItemUpdatedEvent] - Item 'onHours1_Mode' has been updated.

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

2018-06-01 22:06:18.612 [WARN ] [mon.registry.AbstractManagedProvider] - Could not update element with key _tags:onHours1_Temp in ManagedMetadataProviderImpl, because it does not exists.

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

2018-06-01 22:06:18.618 [ome.event.ItemUpdatedEvent] - Item 'onHours1_Temp' has been updated.

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

2018-06-01 22:06:18.620 [WARN ] [mon.registry.AbstractManagedProvider] - Could not update element with key _tags:onHours1 in ManagedMetadataProviderImpl, because it does not exists.

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

2018-06-01 22:06:18.625 [ome.event.ItemUpdatedEvent] - Item 'onHours1' has been updated.

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

2018-06-01 22:06:18.636 [WARN ] [mon.registry.AbstractManagedProvider] - Could not update element with key _tags:g_onHours2 in ManagedMetadataProviderImpl, because it does not exists.

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

2018-06-01 22:06:18.641 [ome.event.ItemUpdatedEvent] - Item 'g_onHours2' has been updated.

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

2018-06-01 22:06:18.643 [WARN ] [mon.registry.AbstractManagedProvider] - Could not update element with key _tags:onHours2_Mode in ManagedMetadataProviderImpl, because it does not exists.

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

2018-06-01 22:06:18.648 [ome.event.ItemUpdatedEvent] - Item 'onHours2_Mode' has been updated.

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

2018-06-01 22:06:18.650 [WARN ] [mon.registry.AbstractManagedProvider] - Could not update element with key _tags:onHours2_Temp in ManagedMetadataProviderImpl, because it does not exists.

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

2018-06-01 22:06:18.655 [ome.event.ItemUpdatedEvent] - Item 'onHours2_Temp' has been updated.

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

2018-06-01 22:06:18.657 [WARN ] [mon.registry.AbstractManagedProvider] - Could not update element with key _tags:onHours2 in ManagedMetadataProviderImpl, because it does not exists.

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

2018-06-01 22:06:18.662 [ome.event.ItemUpdatedEvent] - Item 'onHours2' has been updated.

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

2018-06-01 22:06:18.673 [WARN ] [mon.registry.AbstractManagedProvider] - Could not update element with key _tags:g_onHours3 in ManagedMetadataProviderImpl, because it does not exists.

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

2018-06-01 22:06:18.678 [ome.event.ItemUpdatedEvent] - Item 'g_onHours3' has been updated.

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

2018-06-01 22:06:18.681 [WARN ] [mon.registry.AbstractManagedProvider] - Could not update element with key _tags:onHours3_Mode in ManagedMetadataProviderImpl, because it does not exists.

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

2018-06-01 22:06:18.685 [ome.event.ItemUpdatedEvent] - Item 'onHours3_Mode' has been updated.

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

2018-06-01 22:06:18.687 [WARN ] [mon.registry.AbstractManagedProvider] - Could not update element with key _tags:onHours3_Temp in ManagedMetadataProviderImpl, because it does not exists.

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

2018-06-01 22:06:18.693 [ome.event.ItemUpdatedEvent] - Item 'onHours3_Temp' has been updated.

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

2018-06-01 22:06:18.695 [WARN ] [mon.registry.AbstractManagedProvider] - Could not update element with key _tags:onHours3 in ManagedMetadataProviderImpl, because it does not exists.

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

2018-06-01 22:06:18.702 [ome.event.ItemUpdatedEvent] - Item 'onHours3' has been updated.

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

2018-06-01 22:06:18.714 [WARN ] [mon.registry.AbstractManagedProvider] - Could not update element with key _tags:g_onHours4 in ManagedMetadataProviderImpl, because it does not exists.

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

2018-06-01 22:06:18.721 [ome.event.ItemUpdatedEvent] - Item 'g_onHours4' has been updated.

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

2018-06-01 22:06:18.723 [WARN ] [mon.registry.AbstractManagedProvider] - Could not update element with key _tags:onHours4_Mode in ManagedMetadataProviderImpl, because it does not exists.

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

2018-06-01 22:06:18.728 [ome.event.ItemUpdatedEvent] - Item 'onHours4_Mode' has been updated.

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

2018-06-01 22:06:18.730 [WARN ] [mon.registry.AbstractManagedProvider] - Could not update element with key _tags:onHours4_Temp in ManagedMetadataProviderImpl, because it does not exists.

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

2018-06-01 22:06:18.735 [ome.event.ItemUpdatedEvent] - Item 'onHours4_Temp' has been updated.

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

2018-06-01 22:06:18.737 [WARN ] [mon.registry.AbstractManagedProvider] - Could not update element with key _tags:onHours4 in ManagedMetadataProviderImpl, because it does not exists.

The current items file is

// This is the items file

String Irrigation_Zone1
String Irrigation_Zone2
String Irrigation_Zone3
String Irrigation_Zone4
Switch FrontDownlights "Front Downlights" [ "Switchable" ] 		{ mqtt="<[broker:stat/SmartHouse/Utilities/FrontDownli/POWER:state:default],>[broker:cmnd/SmartHouse/Utilities/FrontDownli/power:command:*:default]" }
Switch SprinklerSystemZone1 "Front Grass Sprinklers" [ "Switchable" ] 	{ mqtt=">[broker:SmartHouse/Utilities/SprinklerSystem:command:ON:Z1ON],>[broker:SmartHouse/Utilities/SprinklerSystem:command:OFF:Z1OFF]" }
Switch SprinklerSystemZone2 "Front Garden Sprinklers" [ "Switchable" ] 	{ mqtt=">[broker:SmartHouse/Utilities/SprinklerSystem:command:ON:Z2ON],>[broker:SmartHouse/Utilities/SprinklerSystem:command:OFF:Z2OFF]" }
Switch SprinklerSystemZone3 "Back Grass Sprinklers" [ "Switchable" ] 	{ mqtt=">[broker:SmartHouse/Utilities/SprinklerSystem:command:ON:Z3ON],>[broker:SmartHouse/Utilities/SprinklerSystem:command:OFF:Z3OFF]" }
Switch SprinklerSystemZone4 "Back Garden Sprinklers" [ "Switchable" ] 	{ mqtt=">[broker:SmartHouse/Utilities/SprinklerSystem:command:ON:Z4ON],>[broker:SmartHouse/Utilities/SprinklerSystem:command:OFF:Z4OFF]" }
Switch GarageDoor "Garage Door" [ "Switchable" ] 			{ mqtt=">[broker:SmartHouse/Utilities/GarageDoor:command:ON:OPEN],>[broker:SmartHouse/Utilities/GarageDoor:command:OFF:CLOSE]" }
Number FrontDownlight_RSSI "Front Downlight: RSSI [%d %%]"  		{ mqtt="<[broker:tele/SmartHouse/Utilities/FrontDownli/STATE:state:JSONPATH($.Wifi.RSSI)]" }
Number Countdown_Zone1 "Minutes Remaining [%d]"
Number Countdown_Zone2 "Minutes Remaining [%d]"
Number Countdown_Zone3 "Minutes Remaining [%d]"
Number Countdown_Zone4 "Minutes Remaining [%d]"                               
Switch SprinklerCycle "30 Minute Cycle" 
Switch SprinklerSystemSchedule1 "Front Grass Schedule"  
Switch SprinklerSystemSchedule2 "Front Garden Schedule" 			
Switch SprinklerSystemSchedule3 "Back Grass Schedule" 			
Switch SprinklerSystemSchedule4 "Back Garden Schedule"
DateTime Irrigation_StartTime1     "Zone 1 Last Watered [%1$ta %1$tR]" 
DateTime Irrigation_StartTime2     "Zone 2 Last Watered [%1$ta %1$tR]" 
DateTime Irrigation_StartTime3     "Zone 3 Last Watered [%1$ta %1$tR]" 
DateTime Irrigation_StartTime4     "Zone 4 Last Watered [%1$ta %1$tR]" 


Group g_onHours1 "Front Grass Sprinkler Minutes" [ "Thermostat" ]
Number onHours1_Mode "Front Grass Sprinkler Minutes Mode" (g_onHours1) [ "homekit:HeatingCoolingMode" ]
Number onHours1_Temp	"Front Grass Sprinkler Minutes Temp" (g_onHours1) [ "CurrentTemperature" ]
Number onHours1 "Front Grass Sprinkler Minutes" (g_onHours1) [ "TargetTemperature" ]

Group g_onHours2 "Front Garden Sprinkler Minutes" [ "Thermostat" ]
Number onHours2_Mode "Front Garden Sprinkler Minutes Mode" (g_onHours2) [ "homekit:HeatingCoolingMode" ]
Number onHours2_Temp	"Front Garden Sprinkler Minutes Temp" (g_onHours2) [ "CurrentTemperature" ]
Number onHours2 "Front Garden Sprinkler Minutes" (g_onHours2) [ "TargetTemperature" ]

Group g_onHours3 "Back Grass Sprinkler Minutes" [ "Thermostat" ]
Number onHours3_Mode "Back Grass Sprinkler Minutes Mode" (g_onHours3) [ "homekit:HeatingCoolingMode" ]
Number onHours3_Temp	"Back Grass Sprinkler Minutes Temp" (g_onHours3) [ "CurrentTemperature" ]
Number onHours3 "Back Grass Sprinkler Minutes" (g_onHours3) [ "TargetTemperature" ]

Group g_onHours4 "Back Garden Sprinkler Minutes" [ "Thermostat" ]
Number onHours4_Mode "Back Garden Sprinkler Minutes Mode" (g_onHours4) [ "homekit:HeatingCoolingMode" ]
Number onHours4_Temp	"Back Garden Sprinkler Minutes Temp" (g_onHours4) [ "CurrentTemperature" ]
Number onHours4 "Back Garden Sprinkler Minutes" (g_onHours4) [ "TargetTemperature" ]

With the current items file, everything works, except i get the warnings, Ill try to play with them and see.
but so far it works