[SOLVED] Mqtt state espurna

Tags: #<Tag:0x00007f2fb54e1ab0>
  • Platform information: Windows 7
    • Hardware: Celeron 32bits/4/250gb
    • OS: W7 SP1
    • Java Runtime Environment: 1.8.0_171-b11
    • openHAB version: 2,2,0
  • Issue of the topic: I have sonoff dual conected to openhab, i can send it comands, but when a I want received state, no do it. I`m subscribe with mqtt.fx to “/casa/persiana/relay/0/” and this option it get state ok, any idea?
  • Please post configurations (if applicable):
    • Items configuration
      Swijtch BlindOffice “Oficina” {mqtt=">[mosquitto:/casa/persiana/relay/0/set:command:default],[mosquitto:/casa/persiana/relay/0/state:state:default]}
    • Sitemap Switch item=BlindOffice
    • Rules code no apply
    • Services configuration no apply
  • If logs where generated please post these here using code fences:

Your inbound binding does have an inbound sign <
Your outbound binding doesn’t have a parameter after command and before defaultIf you wnat ti to be all commads then it needs to be :*:

Switch BlindOffice "Oficina" { mqtt=">[mosquitto:/casa/persiana/relay/0/set:command:*:default],<[mosquitto:/casa/persiana/relay/0/state:state:default]" }

This was all in the docs for the MQTT binding…
Please check and double check the docs before asking on the forum, thanks

Hi

I so sorry, but when i copy code the another pc, i didn,t write < tihs sign i have in the second script inside tihs switch

This code is put in the item file
Switch BlindOffice “Oficina” { mqtt=">[mosquitto:/casa/persiana/relay/0/set:command:*:default],<[mosquitto:/casa/persiana/relay/0/state:state:default] }

sorry again

Please use the code fences when posting code

You are missing a " at the end of the binding

Switch BlindOffice "Oficina" { mqtt=">[mosquitto:/casa/persiana/relay/0/set:command:*:default],<[mosquitto:/casa/persiana/relay/0/state:state:default]" }

Try not to copy and paste code.
It’s better to write it down for two reasons.

  1. Sometimes hidden characters are copied and pasted
  2. You will actually learn your code

Does it work now?

Hi

Not working

This is my last test
Item file
Switch BlindOfficeUp “Oficina subir” { mqtt=">[mosquitto:/casa/planta/baja/persiana/patio/relay/0/set:command:*:default],
<[mosquitto:/casa/planta/baja/persiana/patio/relay/0/state:state:default]"}

sitemap item
Switch item=BlindOfficeUp

And mqtt.fx
I subscribed:
/casa/planta/baja/persiana/patio/relay/0 --> received state

Did you mean:
/casa/planta/baja/persiana/patio/relay/0/state --> ON or OFF?

You need to subscribe to the same topic

Or subscribe to /casa/planta/baja/persiana/#
To get ALL the traffic for the persiana

Yes, but if i write in comand item

Switch BlindOfficeUp “Oficina subir” { mqtt=">[mosquitto:/casa/planta/baja/persiana/patio/relay/0/set:command:*:default],
<[mosquitto:/casa/planta/baja/persiana/patio/relay/0:state:default]"}
In log
2018-05-14 12:27:06.460 [WARN ] [b.core.events.EventPublisherDelegate] - given new state is NULL, couldn’t post update for ‘BlindOfficeUp’

I don,t undestand

Another think, sonnof dual has configuration:
If switch 0 is on and switch 1 change to on,then switch 0 change to OFF automatic by configuration spurna, mqtt.fx received new status switch 0 always

Me neither,

What do you mean?

With the item as it is just above, when you action the switch on your UI, you will see a message ON or OFF in the topic casa/planta/baja/persiana/patio/relay/0/set
in MQTTfx

But there is an error in your inbound binding, the topic is :/casa/planta/baja/persiana/patio/relay/0 and should be :/casa/planta/baja/persiana/patio/relay/0/state

So your item should be:

Switch BlindOfficeUp "Oficina subir" { mqtt=">[mosquitto:/casa/planta/baja/persiana/patio/relay/0/set:command:*:default],<[mosquitto:/casa/planta/baja/persiana/patio/relay/0/state:state:default]" }

And use the code fences

Ok, I didn’t use espurna before so I had a look at the docs.
The root topic in your espurna need to be: '/casa/planta/baja/persiana/patio`

Espurna relays respond to the payload 0 or 1 so we need to tell openHAB to change 0 into OFF and 1 into ON and vice versa

So your item should be:

OfficeUp "Oficina subir" { mqtt=">[mosquitto:/casa/planta/baja/persiana/patio/relay/0/set:command:*:MAP(ohtoespurna.map)],<[mosquitto:/casa/planta/baja/persiana/patio/relay/0:state:MAP(espurnatooh.map)]" }

Create a file called ohtoespurna.map in your transform folder with the following contents:

-=Undef
NULL=NULL
OFF=0
ON=1

Create another file called espurnatooh.map in your transform folder with the following contents:

-=Undef
NULL=NULL
0=OFF
1=ON
1 Like

That´s right

Is ok now, thk so much for this it, now i undestand file map and payload to espurna.

Thank you again, lets go for my blinds now

Very Helpful Solution , Thank you

Can you help me on setting up a COLOR LED bulb flashed with espurna? ESPURNA software gives settings for home assistant but not for openhab. Here is the code they supply

light:
  - name: ESPLIGHT1
    platform: mqtt
    state_topic: ESPLIGHT1/relay/0
    command_topic: ESPLIGHT1/relay/0/set
    payload_on: 1
    payload_off: 0
    availability_topic: ESPLIGHT1/status
    payload_available: 1
    payload_not_available: 0
    brightness_state_topic: ESPLIGHT1/brightness
    brightness_command_topic: ESPLIGHT1/brightness/set
    rgb_state_topic: ESPLIGHT1/rgb
    rgb_command_topic: ESPLIGHT1/rgb/set
    color_temp_command_topic: ESPLIGHT1/mired/set
    white_value_state_topic: ESPLIGHT1/channel/3
    white_value_command_topic: ESPLIGHT1/channel/3/set

Any help is appreciated

Ok
So you neet the mqtt binding:


and read that too:

Then you need to send an rgb payload to the topic ESPLIGHT1/rgb/set
According to the ESPurna wiki:


You need to send the payload #FF0000 or 255,0,0 for RED

It’s all in the docs!