Comments (7)
Based on the info you provided, it looks like the state_topic
needs to be zigbee2mqtt/Friendly_name
. The state topic is the topic Moonraker subscribes to and listens for updates. The "zigbee2mqtt" client should publish all updates to this topic. If the zigbee sets the retain flag on this topic then the query_topic
is optional.
Again, based on the info provided, the query_topic
appears it should be zigbee2mqtt/Friendly_name/get/state
, with no payload.
from moonraker.
Unfortunately I can't help with setting up Mainsail, as its a separate project. Moonraker just exposes the APIs which frontend applications like Mainsail can choose to implement. I don't know if Mainsail can show data from generic sensors or how to configure it if it can.
from moonraker.
Without moonraker.log
it isn't clear what is happening with the command topic, but I suspect the primary issue is that the device can't initialize and thus commands won't be sent. If you need to send a payload with the query topic you need to configure the query_payload
option (see the docs. You can use Jinja2 to encode a dict to json if that is what is required for your zigbee client. Moonraker has some brief Jinja2 docs, and the full Jinja template documentation is available here.
from moonraker.
Thank for your reply! Uploaded below moonraker.log and klippy.log with no usefull log
Ok, if I set
command_topic: zigbee2mqtt/Friendly_name/set/state
command_payload: {command}
query_topic: zigbee2mqtt/Friendly_name/set/state
query_payload: toggle
The Zigbee2mqtt device toggle in loop ON-OFF every 5 seconds because of query_topic that works as SET and not GET the state
But the Power button doesn't work, so I suppose that is necessary to configure correctly the query_topic that it's needed to enable command_topic
I tested with MQTTX (client mqtt)
zigbee2mqtt/Friendly_name/get
zigbee2mqtt/Friendly_name/get state
give me
Zigbee2MQTT:error 2024-03-26 22:51:08: Invalid message 'null', skipping...
If use
zigbee2mqtt/Friendly_name/get/state
I obtain
Zigbee2MQTT:info 2024-03-26 22:52:12: MQTT publish: topic 'zigbee2mqtt/Friendly_name', payload '{"current":0,"energy":0,"indicator_mode":"off/on","linkquality":232,"over_current_breaker":"ON","over_current_threshold":65,"over_voltage_breaker":"ON","over_voltage_threshold":265,"power":0,"power_breaker":"ON","power_outage_memory":"restore","power_threshold":13,"state":"ON","temperature":26.94,"temperature_breaker":"ON","temperature_threshold":100,"under_voltage_breaker":"ON","under_voltage_threshold":75,"update":{"installed_version":-1,"latest_version":-1,"s
So I don't need query_payload, right?
Otherwise I can use it with
zigbee2mqtt/Friendly_name/get {"state": ""}
I obtain the payload with MQTTX
but If I set
query_topic: zigbee2mqtt/Friendly_name/get
query_payload: {"state": ""}
The Power Button Disappear because the correct Jinja2 output should be
query_payload: {'{"state": ""}'}
Correct it, Power still no work
I try
query_topic: zigbee2mqtt/Friendly_name/get/state
query_payload: state
MQTTX obtain payload, But the Power button still no work
If I set
state_topic: zigbee2mqtt/Friendly_name/set/state
state_response_template: toggle
Power button disappear
state_topic: zigbee2mqtt/Friendly_name/get/state
state_response_template: state
Power Button goes dark
###################################
###################################
For my reminder
Button Name (MQTT) goes dark:
###################################
state_topic: zigbee2mqtt/Friendly_name/get
state_response_template: {'{"state": ""}'}
query_topic: zigbee2mqtt/Friendly_name/get
query_payload: {'{"state": ""}'}
###################################
state_topic: zigbee2mqtt/Friendly_name/get/state
state_response_template: state
{% set resp = payload|fromjson %}
{ resp["state"]|lower }
###################################
state_topic: zigbee2mqtt/Friendly_name/get/state
state_response_template: state
###################################
state_topic: zigbee2mqtt/Friendly_name/get/state
state_response_template:
###################################
state_topic: zigbee2mqtt/Friendly_name/get/state
state_response_template:
query_topic: zigbee2mqtt/Friendly_name/get/state
query_payload:
###################################
state_topic: zigbee2mqtt/Friendly_name/get/state
state_response_template: state
query_topic: zigbee2mqtt/Friendly_name/get/state
query_payload: state
###################################
state_topic: zigbee2mqtt/Friendly_name/get
state_response_template:
{% set resp = payload|fromjson %}
{ resp["state"]|lower }
query_topic: zigbee2mqtt/Friendly_name/get
query_payload: {'{"state": ""}'}
###################################
###################################
###################################
Button Name (MQTT) goes light:
###################################
state_topic: zigbee2mqtt/Friendly_name/get
state_response_template: {payload}
###################################
state_topic: zigbee2mqtt/Friendly_name/set
state_response_template: state
###################################
state_topic: zigbee2mqtt/Friendly_name/get
state_response_template:
{% set resp = payload|fromjson %}
{ resp["state"]|lower }
query_topic: zigbee2mqtt/Friendly_name/get/state
query_payload: state
###################################
state_topic: zigbee2mqtt/Friendly_name/get
state_response_template:
{% set resp = payload|fromjson %}
{ resp["state"]|lower }
query_topic: zigbee2mqtt/Friendly_name/get/state
query_payload: {'{"state": ""}'}
from moonraker.
Thank you, now it works, you earned a ko-fi
The issue was the state_topic: that want "zigbee2mqtt/Friendly_name" and not "zigbee2mqtt/Friendly_name/get"
[power MQTT]
type: mqtt
command_topic: zigbee2mqtt/Friendly_name/set/state
command_payload: {command}
state_topic: zigbee2mqtt/Friendly_name
state_response_template:
{% set resp = payload|fromjson %}
{ resp["state"] }
query_topic: zigbee2mqtt/Friendly_name/get/state
query_after_command: false
locked_while_printing: true
from moonraker.
Now I'm configuring the powermeter function with
[sensor mqtt_powermeter]
type: mqtt
name: Powermeter
state_topic: zigbee2mqtt/Friendly_name
state_response_template:
{% set notification = payload|fromjson %}
{set_result("power", notification["apower"]|float)}
{set_result("voltage", notification["voltage"]|float)}
{set_result("current", notification["current"]|float)}
But the documentation is poor to understand how show in Mainsail those sensor values.
from moonraker.
As the original issue has been resolved I'm going to close this.
from moonraker.
Related Issues (20)
- Ensure time is synced before refreshing the update manager status. HOT 1
- Power locked_while_printing: True asserting at startup when not printing HOT 5
- Cannot Retrieve File Metadata for Spoolman HOT 10
- Spoolman Proxy: Include total count header in response
- How to add Authenticator HOT 2
- unable get printer info from moonraker HOT 5
- Gcode-shell-command Error: Failed to restart KlipperScreen.service: Interactive authentication required. HOT 2
- Can the file manager API also return a hash? HOT 7
- Fluidd Moonraker connection to elegoo Neptune 4+ on MAC failed (Force Refresh) HOT 5
- Add Flatpack
- Apprise update. HOT 2
- Add option to power off a power device when operating system shutdown. HOT 2
- Non working links for ids.
- Power device: add option to run custom gcode on on/off action
- [database.py:insert_item()] - Error inserting key 'instance_id' in namespace 'moonraker' HOT 5
- Login fails after upgrade HOT 9
- Missing Documentation for altering the instance_uuid HOT 3
- Add filament Iād to print history
- Mainsail cannot connect to Moonraker (connection Failed) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ššš
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from moonraker.