MQTT IMPORT - HOWTO!!!!! WORKING

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
pw444
Normal user
Posts: 155
Joined: 23 Apr 2019, 15:34
Location: rio de janeiro

MQTT IMPORT - HOWTO!!!!! WORKING

#1 Post by pw444 » 26 Dec 2020, 14:22

Hya,

is there a documentation with examples of MQTT IMPORT plugin?

Thx in advance!
Last edited by pw444 on 26 Dec 2020, 22:21, edited 1 time in total.

User avatar
Ath
Normal user
Posts: 3519
Joined: 10 Jun 2018, 12:06
Location: NL

Re: MQTT IMPORT - howto?

#2 Post by Ath » 26 Dec 2020, 14:58

Have you tried clicking the (?) icon near the device name? It will take you to the Wiki documentation, that is a bit outdated, but only in PR#3424 where JSON support, filtering and value mapping will be added, I've updated the ReadTheDocs page. (That page is currently quite empty.)
I haven't added many examples in that new documentation, but the current MQTT Import plugin will only handle a single numeric Value per topic.
You can use rules to react on a changing topic value, as each change there generates an event, or use the value(s) on a display.
/Ton (PayPal.me)

pw444
Normal user
Posts: 155
Joined: 23 Apr 2019, 15:34
Location: rio de janeiro

Re: MQTT IMPORT - howto?

#3 Post by pw444 » 26 Dec 2020, 15:34

Ok, thank you. i will try out and post the doubts, if you don't mind.

pw444
Normal user
Posts: 155
Joined: 23 Apr 2019, 15:34
Location: rio de janeiro

MQTT IMPORT - HOWTO!!!!! WORKING

#4 Post by pw444 » 26 Dec 2020, 22:20

Got it:

on HA configuration.yaml

Code: Select all

# Kaffeemaschine
binary_sensor km:
  - platform: mqtt
    name: "TC91100"
    unique_id: tc91100
    state_topic: "BSTC91100/VACC/status"
#   state_topic: "BSTC91100/gpio/4"
    payload_on: "1"
    payload_off: "0"
    availability:
    - topic: "BSTC91100/status/LWT"
      payload_available: "Online"
      payload_not_available: "Offline"


switch km:
  - platform: mqtt
    name: "cups 5-8"
#   unique_id: tc91100b58
    state_topic: "BSTC91100/B58/status"
    command_topic: "BSTC91100/B58/status"
    payload_on: "1"
    payload_off: "0"
  - platform: mqtt
    name: "cups 2-4"
#   unique_id: tc91100b24
    state_topic: "BSTC91100/B24/status"
    command_topic: "BSTC91100/B24/status"
    payload_on: "1"
    payload_off: "0"
  - platform: mqtt
    name: "off"
#   unique_id: tc91100boff
    state_topic: "BSTC91100/BOFF/status"
    command_topic: "BSTC91100/BOFF/status"
    payload_on: "1"
    payload_off: "0"
    
    
my rules:

Code: Select all

// B58  gpio 14 - D5
// B24  gpio 12 - D6
// BOFF gpio 13 - D7

On System#Boot do 
  let,1,0
  let,2,0
  let,3,0
  timerSet,1,3
endon

On Rules#Timer=1 do //When Timer1 expires, do
  if %v2%=0 and %v3%=0
    pulse,2,1,200  // pulse    
    let,2,1
    timerSet,1,1 
  else
    let,2,0
    timerSet,1,2 //Resets the Timer 1 for another X seconds
  endif 
endon

on MQTT#Connected do
   let,3,0
   event,publishstatus
endon

on MQTT#Disconnected do
  let,3,1
endon


//by http

On B58 do  
  pulse,14,1,500
  pulse,2,0,500
  let,1,1
  Publish,%sysname%/B58/status,0
endon

On B24 do
  pulse,12,1,500
  pulse,2,0,500
  let,1,1
  Publish,%sysname%/B24/status,0
endon 

On BOFF do
  pulse,13,1,500
  pulse,2,0,500
  Publish,%sysname%/BOFF/status,0
  let,1,2
endon

//by MQTT

on MQTTIN#BOFF do // cancelled
  if %eventvalue%=1
     logentry,"mqt boff"
     pulse,13,1,500
     pulse,2,0,500
     Publish,%sysname%/BOFF/status,0
     let,1,2
  endif
endon

on MQTTIN#B58 do // brew 5-8
  if %eventvalue%=1
     logentry,"mqt b58"
     pulse,14,1,500
     pulse,2,0,500
     Publish,%sysname%/B58/status,0
     let,1,1
  endif
endon

on MQTTIN#B24 do // brew 2-4
  if %eventvalue%=1
     logentry,"mqt b24"
     pulse,12,1,500
     pulse,2,0,500
     Publish,%sysname%/B24/status,0
     let,1,1
  endif
endon

on VACC#status do
  if %eventvalue%=1
    if %v1%=1        
       Publish,%sysname%/Notify/status,1  // working
    endif
  else               // status = 0
    if %v1%=1        // status = 0 var1 =1
       let,1,0
       Publish,%sysname%/Notify/status,0   // finished
    endif 
    if %v1%=2        // status = 0 var1 =2
       let,1,0
       Publish,%sysname%/Notify/status,2   // cancelled
    endif
  endif
endon
for sure i will have to fine tune it, but, it's working.

Thx for pointing the PR#3424
Attachments
hardware.png
hardware.png (155 KiB) Viewed 9257 times
devices.png
devices.png (186.08 KiB) Viewed 9257 times
mqttimport.png
mqttimport.png (46.63 KiB) Viewed 9257 times

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 93 guests