OpenHAB + Wemos D1 ...
 
Powiadomienia
Wyczyść wszystko

openHAB OpenHAB + Wemos D1 mini + MQTT + NeoPixel

4 Wpisów
2 Użytkownicy
0 Likes
205 Wyświetleń
(@szpila86)
Wpisów: 330
Weteran Patron Strony Donator 2K22, Donator 2K23, Donator 2K24
Autor tematu
 

Hej

 

Mały projekcik "lampki" LED z pomiarem temp i dwoma przyciskami

niby prosta sprawa ale zabłądziłem... Na ESP wrzucone EspEasy które wymienia dane przez MQTT z OH (przynajmniej w teorii)

 

things

Bridge  mqtt:broker:Sara_Sw "Sara_Broker" [ host="192.168.xx.xx", port="1883", secure=false, clientID="OH3-Sara" ]
{
    Thing topic Sara_SW1 "Sara_Switch" { 
    Channels:
        Type switch : state "Sara_SW1" [
            stateTopic="NeoPixel/Wlacznik1/State",
            on="1", 
            off="0"]
    }  

    Thing topic Sara_SW2 "Sara_Switch" {
    Channels:
        Type switch : state "Sara_SW2" [ 
            stateTopic="NeoPixel/Wlacznik2/State",
            on="1", 
            off="0"]   
    }

    Thing topic Sara_Neo "Sara_Switch" {
    Channels:
        Type color : RGBW_Led_Sara "Sara_Neo" [ 
            stateTopic="NeoPixel/Neo/cmd"]   
    }

 

items

Switch      Sara_SW1       "Przycisk 1"     <my_suspend>         {channel="mqtt:topic:Sara_Sw:Sara_SW1:state"}
Switch      Sara_SW2       "Przycisk 2"     <my_suspend>         {channel="mqtt:topic:Sara_Sw:Sara_SW2:state"} 
String      Sara_SW_LWT    "Sara właczniki" <qualityofservice>   {channel="mqtt:topic:Sara_Sw:LWT:Connected" }
 
Number      Sara_Sensor    "Temp [%.2f °C]" <temperature>        {channel="mqtt:topic:Sara_Sw:DS:Temperature"} 
 
Number       RGBW_Led_Sara  "RGBW_Sara"                            {channel="mqtt:topic:Sara_Sw:Sara_Neo:RGBW_Led_Sara"}
Number      H_slider       "Barwa"          <colorpicker>
Dimmer      S_slider       "Nasycenie"      <colorlight>
Dimmer      B_slider       "Jasność"        <slider>

 

rules

rule "test"
when  
  Item Sara_SW1 changed or
  Item Sara_SW2 changed
then
  if (Sara_SW1.state==ON ) {
    OswDzien.sendCommand(ON)
  } else {
    OswDzien.sendCommand(OFF)
  }
    if (Sara_SW2.state==ON ) {
    OswPp.sendCommand(ON)
  } else {
    OswPp.sendCommand(OFF)
  } 
end 

rule "RGBW Color Control Rule"
when 
  Item H_slider received update or  
  Item S_slider received update or
  Item B_slider received update
then
  RGBW_Led_Sara.sendCommand("NeoPixelAllHSV,"+
    H_slider.state + "," + 
    S_slider.state + "," + 
    B_slider.state
  )
end

 

sitemaps

Switch		item=Sara_SW1			mappings=[ON="wlacz", OFF="wylacz"]
Switch		item=Sara_SW2			mappings=[ON="wlacz", OFF="wylacz"]
Slider 		item=H_slider 			minValue=0 maxValue=360
Slider 		item=S_slider
Slider 		item=B_slider
Default		item=Sara_Sensor  
Default		item=Sara_SW_LWT

 

Nie działa tylko zmiana kolorów. Proszę o pomoc 🙂

 
Dodane : 14/10/2023 6:34 pm
(@szpila86)
Wpisów: 330
Weteran Patron Strony Donator 2K22, Donator 2K23, Donator 2K24
Autor tematu
 

gdy daję na testy do przycisku

val mqttActions = getActions("mqtt", "mqtt:broker:Sara_Sw") 
mqttActions.publishMQTT("NeoPixel/Neo/cmd", "NeoPixelAllHSV,16.0,100.0,50.0") 

działa wysyłanie do mqtt i wemos reaguje ale powstaje przy okazji w logach

 Item 'Sara_SW1' received command ON
 Item 'Sara_SW1' predicted to become ON

 Command 'NeoPixelAllHSV,16.0,100.0,50.0' from channel 'mqtt:topic:Sara_Sw:Sara_Neo:RGBW_Led_Sara' not supported by type 'ColorValue': NeoPixelAllHSV,16.0,100.0,50.0 is not a valid string syntax

 Item 'Sara_SW1' changed from OFF to ON

gdzie zabłądziłem?

 
Dodane : 15/10/2023 1:17 pm
(@kamikac)
Wpisów: 226
Pomocny
 

Nie możesz mieć thing color, skoro chcesz wysłać string.

Trocę to przekombinowane. Ja bym zrobił bez rules: item color i w thing (string) zformatował wyjście dodając

formatBeforePublish = "NeoPixelAllHSV,%s"

Ale ja nie mam żadnych urządzeń RGB, więc mogę nie jestem pewien.

 
Dodane : 15/10/2023 6:04 pm
(@szpila86)
Wpisów: 330
Weteran Patron Strony Donator 2K22, Donator 2K23, Donator 2K24
Autor tematu
 

@kamikac 

Hehe ja mam chyba na drugie "komplikacje" ale główny moim problemem okazał się uszkodzony esp.

Całość działa, dzieci zadowolone.

Dzięki 😉

 
Dodane : 17/10/2023 7:26 pm
Udostępnij: