Chibald / maestrogateway

Manage MCZ pellet stoves that are equipped with Maestro technology
GNU General Public License v3.0
38 stars 13 forks source link

README.md is missing examples #4

Closed tharts closed 3 years ago

tharts commented 4 years ago

Since the scripts are meant as a way to control an MCZ stove from Openhab2 it would be helpful if there were additional informations and examples how to configure the mqtt broker, giving examples how to configure things and items.

Chibald commented 4 years ago

i'll add some directions as how i'm using this when i find the time to write it up.

But it comes down to this: I's monitoring the PUBmcz mqtt topic for messages and bind that to my items like:

Number  Maestro_Control_Mode                        { mqtt="<[mosquitto:PUBmcz:state:JSONPATH($.Control_Mode):.*Control_Mode.*]" }
Number  Maestro_Power_Level                         { mqtt="<[mosquitto:PUBmcz:state:JSONPATH($.Power_Level):.*Power_Level.*]" }
Number  Maestro_ECO_Mode                            { mqtt="<[mosquitto:PUBmcz:state:JSONPATH($.ECO_Mode):.*ECO_Mode.*]" }
Number  Maestro_Chrono_Mode                         { mqtt="<[mosquitto:PUBmcz:state:JSONPATH($.Chrono_Mode):.*Chrono_Mode.*]" }
Number  Maestro_Silent_Mode                         { mqtt="<[mosquitto:PUBmcz:state:JSONPATH($.Silent_Mode):.*Silent_Mode.*]" }
Number  Maestro_Fan_State                           { mqtt="<[mosquitto:PUBmcz:state:JSONPATH($.Fan_State):.*Fan_State.*]" }

There are many more items.

Also, inside a rules file i have a rule that will send a Json message to the SubMcz topic like:

rule "Maestro_Silent_Mode"
when
    Item Maestro_Silent_Mode changed
then
    publish("mosquitto", "SUBmcz", '{\"Command\": "Silent_Mode", \"Value\": \"' + Maestro_Silent_Mode.state.toString + '\"}')    
end

bear in mind i'm at a bit outdated version of openhab (2.1) using the openhab 1 mqtt binding. It should be easier on newer openhab- versions.

tharts commented 4 years ago

I'd like to add the configuration which I use with OH2 MQTT2 Binding and Mosquitto (OH2's embedded broker should work as well, but haven't tried it yet).

Things-Configuration:

broker.things: mqtt:broker:myUnsecureBroker [ host="<broker-host>", secure=false ]

Broker host is the IP or hostname of the MQTT-Broker. If running on the same server with OH2 then localhost or 127.0.0.1 should be fine.

mqtt.things: Bridge mqtt:broker:myUnsecureBroker [ host="<broker-host>", secure=false ] { Thing mqtt:topic:mything { Channels: Type switch : mczPower "MCZ Power" [ commandTopic = "SUBmcz", on="{ \"Command\": \"Power\", \"Value\": 1}", off="{ \"Command\": \"Power\", \"Value\": 0}" ] Type string : mczStatus "MCZ Status" [ stateTopic = "PUBmcz" ] } }

For other commands besides "Power" one has to make sure that the correct json is send. Maybe sometimes it's easier to use a rule for that.

Items:

String Maestro_Control_Mode "MCZ Control Mode" (gGF_Livingroom) { channel="mqtt:topic:mything:mczStatus"[profile="transform:JSONPATH",function="$[?(@.Control_Mode)].*Control_Mode"] } String Maestro_Power_Level "MCZ Power Level" (gGF_Livingroom) { channel="mqtt:topic:mything:mczStatus"[profile="transform:JSONPATH",function="$[?(@.Power_Level)].*Power_Level"] } String Maestro_ECO_Mode "MCZ ECOO Mode" (gGF_Livingroom) { channel="mqtt:topic:mything:mczStatus"[profile="transform:JSONPATH",function="$[?(@.Maestro_ECO_Mode)].*Maestro_ECO_Mode"] } String Maestro_Chrono_Mode "MCZ Chrono Level" (gGF_Livingroom) { channel="mqtt:topic:mything:mczStatus"[profile="transform:JSONPATH",function="$[?(@.Maestro_Chrono_Mode)].*Maestro_Chrono_Mode"] } String Maestro_Silent_Mode "MCZ Silent Mode" (gGF_Livingroom) { channel="mqtt:topic:mything:mczStatus"[profile="transform:JSONPATH",function="$[?(@.Maestro_Chrono_Mode)].*Maestro_Chrono_Mode"] } String Maestro_Fan_State "MCZ Fan Level" (gGF_Livingroom) { channel="mqtt:topic:mything:mczStatus"[profile="transform:JSONPATH",function="$[?(@.Maestro_Fan_State)].*Maestro_Fan_State"] }

The jsonPath expressions return NULL when the property is not in the Json, otherwise they return the value.

Sitemap:

`sitemap MyHome label="MCZ" {

Frame {
    Group item=gGF_Diningroom
}

Frame {
    Text label="Stove" icon="fire" {
        Switch item=mczSwitch label="Stove" 
        Default item=mczOfen label="Stove status [%s]"
        Default  item=Maestro_Control_Mode  
        Default  item=Maestro_Power_Level
        Default  item=Maestro_ECO_Mode 
        Default  item=Maestro_Chrono_Mode
        Default  item=Maestro_Silent_Mode
        Default  item=Maestro_Fan_State  
    }
}

} `

Chibald commented 4 years ago

Ah your configuration looks more compact than mine! The mqtt version 2 binding looks very compact. I use the rules system to send the commands. As it is working i'm bit hestitant tho touch it because it works very well for us right know, and i don't want to wake up in a cold house ;)

I 've added to the wiki the transformations and other configuration I use. You should be able to take full control of your stove via Openhab if you change the files a bit.

deSteini commented 3 years ago

Hi guys, I would like to pick this topic up again. I am new to openHab, but do have some programming experience (C, C+, Python...) . I also understand the concept of MQTT. Still I have some questions about the usage here:

  1. From my understanding, the MCZ Oven can be "read" and "written" with the subscribe and publish methods of the MQTT. For what do we actually need this repository then? I see in the python code, that it provides some getter for the different commands. But what else is it doing? Do we actually need to "run" it? And where in your Wiki entries or in the Code example above are you using it? Or how?

  2. It seems to me that the "publish" routine within the rules does not work anymore for MQTT2 @Chibald . Just copying the code snippets from @tharts and replacing the host is also not working for me (VS Code shows some invalid syntax). Do you think it's possible to add a complete example for MQTT2 to the Wiki which can read and write something to the oven?

  3. Setup of the PI: Did you just connect your PI to the ethernet and afterwards connected it also to the SSID of the oven and it worked? Or did you have to configure this Wifi/LAN combination somehow else and could give a hint for it?

I would be glad if you could help me getting started with the automatization of my oven =) Btw. it's an Vivo90

Thanks in Advance!

Chibald commented 3 years ago

Hi @deSteini

  1. MCZ uses the "maestro" interface communicate with the "real" phone app using a websocket. This means there are some proprietary commands that are used to communicate between the phone app and the stove. This scrips acts as a proxy between the stove and your network, porting the websocket command to more readable mqtt messages.

  2. I dont use the new mqtt2 binding myself so I cant help you with that for now.

  3. The Pi needs to be connected via WIFI directly to the stove, and via ethernet to your own LAN. (The pi needs to be realy close to the stove as well for best results)

deSteini commented 3 years ago

Hi @Chibald thanks for the clarification. Now I understand why we need the script. I must have overread this part in the readme...

In case I finally make it run with mqtt2 I would also insert my Setup/experience here. This might help others as well.

I am currently trying to connect the PI to the oven, but somehow, it doesn't work. He can find the corresponding SSID, but is not connecting properly to it. Did you have similar experience? It seems for me, my PI is either using the ethernet connection, or the WiFi. Do you remember how you had to configure it that both worked? The PI is not yet close to the ofen. Does it need to be, that the connection is working at all, or only that the performance is good?

Chibald commented 3 years ago

Hi deSteini

My experience is that you either have to move your pi right up to your stove, of you have to get a external wifi with antennas that you can point right at the stove.

Otherwise you will lose Wifi onnection all the time. I Guess there is just a simple arduino based wifi inside the stove, with a really weak antenna.

You can check your connection drops in the logs of your pi.