How to link MQTT2 publish/subscribe topics to frontend objects like switches etc

Begonnen von bmentink, 04 September 2019, 05:15:54

Vorheriges Thema - Nächstes Thema

bmentink

Hi All,

I am a new user to FHEM. I am having a lot of trouble just getting some basic concepts under my belt.

So far I have created a MQTT2_SERVER and a MQTT2_DEVICE and I can see all the published messages from my attached custom mqqt device. I have logging turned on for that device so I can log data so far so good.

What I am having trouble with is linking switches/sliders etc to MQTT topics for the "device"

Have a look at the attached device picture and can anyone answer the following?

1. How do I set up a simple ON:OFF switch that publishes a topic, when the switch changes state  (i.e how do I connect a switch to a topic, I.E. dc_4f_22_18_e3_f5_72:/Garden/Aeroponics/Pump)

2. An example of a "slider" control sending a topic to the mqtt server when it changes value. (I.E. I want to send changes to dc_4f_22_18_e3_f5_72:/Garden/Aeroponics/Threshold)

3. I want to see in my Aeroponics ROOM the value of dc_4f_22_18_e3_f5_72:/Garden/Aeroponics/SolarIntensity,  it has the readingList item SolarIntensity)

I have gone through the tutorial with a "dummy" switch, but that does not help me with a REAL switch ..

Many Thanks

supernova1963

Zitat von: bmentink am 04 September 2019, 05:15:54
1. How do I set up a simple ON:OFF switch that publishes a topic, when the switch changes state  (i.e how do I connect a switch to a topic, I.E. dc_4f_22_18_e3_f5_72:/Garden/Aeroponics/Pump)
2. An example of a "slider" control sending a topic to the mqtt server when it changes value. (I.E. I want to send changes to dc_4f_22_18_e3_f5_72:/Garden/Aeroponics/Threshold)
3. I want to see in my Aeroponics ROOM the value of dc_4f_22_18_e3_f5_72:/Garden/Aeroponics/SolarIntensity,  it has the readingList item SolarIntensity)

Do you've tried something like this:

attr MQTT2_AERO setList\
    on /Garden/Aeroponics/Pump 1\
    off /Garden/Aeroponics/Pump 0\
    state:slider,0,1,100 /Garden/Aeroponics/Threshold $EVTPART1
attr MQTT2_AERO stateformat state\
stateSolarIntensity
attr webcmd state:on:off

bmentink

Thanks for the reply.

Can you explain the setList a bit?

1. I don't see how the on/off references the Pump topic. Do you mean that the word "topic" should be replaced by "Pump"?
2. You have created a slider, how does that link to the SolarIntensity topic?

Cheers,

Beta-User

See also the answer to the same questions here:

https://forum.fhem.de/index.php/topic,103425.msg971819.html#msg971819

I'll make some annotations to the differences wrt. the on/off thing later in the other thread, as this may be valueable for others also.

First and most important step is to get the thing switched in the real world, the other things are more about useability and reasonable bidirectional communication ;) .

So is there any description on the MQTT interface of your Aeroponics system? Especially: you provided (some) info about the topic structure, but not really about the payload (seemed to be ON and OFF wrt. to the pump) nor the range of the threshold.

@mnetink: I'd suggest to do a step by step procedure and start of with the pump (that seems to be the central unit in the system...).
Server: HP-elitedesk@Debian 12, aktuelles FHEM@ConfigDB | CUL_HM (VCCU) | MQTT2: MiLight@ESP-GW, BT@OpenMQTTGw | MySensors: seriell, v.a. 2.3.1@RS485 | ZWave | ZigBee@deCONZ | SIGNALduino | MapleCUN | RHASSPY
svn: u.a MySensors, Weekday-&RandomTimer, Twilight,  div. attrTemplate-files

bmentink

Hi All,

Please jump across to: https://forum.fhem.de/index.php/topic,103425.0.html
..as this post doubles up ..

Thanks,