mjcumming / homie4 Goto Github PK
View Code? Open in Web Editor NEWPython package for Homie v4 specification
License: MIT License
Python package for Homie v4 specification
License: MIT License
Is there a way to retrieve the node id from a topic programmatically?
I'm working on a project that uses dynamically generated nodes, so I'd like to either be able to pass the node id to set_value of the property, or be able to retrieve it from the called function, to be able to set the value to the correct variable based on the node id.
Is this possible, or is it easier to have the far end client (openhab) pass the node id as part of the value?
Thanks,
Jason
This is a rather basic usage question I can't figure out: Is it possible to set up an class that contains 2 or more existing basic devices ?
Let's say an audio device that would contain a device_switch for power and a device_dimmer for volume ? Or does it have to be written from scratch as device_audio with the add_node commands ?
date time property doesn't work
I think the date format should be changed to% Y-% m-% dT% H:% M:% S.% f (with "T") as suggested in the discussion homieiot/convention#160. It's according to ISO8601
There is a problem in this place.
Should it be username_pw_set instead set_auth_credentials ?
https://github.com/mjcumming/homie4/blob/b3c663b29b338c8910ebbc89773027ddf8c3f36e/homie/mqtt/paho_mqtt_client.py#L76
Do you have a generic example to create a device with multiple nodes and multiple properties per node?
What I want to do is create an 'air quality' device, that has nodes for pollution and allergens, with the levels of each made available through properties.
G'day,
I think the logic of the get_payload_from_value() method in the Property_Contact class is inversed
I'm presuming the intent of the contact property is for a contact switch (like a door sensor) - which is what I am using it for. So wouldn't you want the value to be false when open (i.e. not contacted) and true when closed (i.e. when in contact)?
At the moment, the logic of that method is inversed.
Thoughts?
Regards,
Christopher
G'day,
I have a device lass called My_Relay which inherits from Device_Switch.
I am wanting to add an additional property to the switch node.
class My_Relay(Device_Switch):
def __init__(
self, device_id=None, name=None, homie_settings=None, mqtt_settings=None
):
super().__init__(device_id, name, homie_settings, mqtt_settings)
self.get_node("switch").add_property(Property_DateTime(self, id="datetime", name="Date and Time"))
...
But when I run it, I get an AttributeError:
AttributeError: 'My_Relay' object has no attribute 'property_publisher'
I can't figure out why that error is being raised. My thoughts are that the __init__()
method of the Device_Switch class is invoking the start()
method, which does the publish of nodes, attributes, etc. So when I am attempting to add the further property it is too late.
Is that correct? Is there a way to do this or do I need to create another device class based on the Device_Base
class that replicates almost all of the Device_Switch
class?
Thanks,
Christopher
Hi,
I can't seem to see any support for MQTT Websockets transport, would that be of interest ?
Property_Boolean uses the standard python string representations for booleans, which is True and False. Instead, it should always send the lowercase version (true and false)
https://homieiot.github.io/specification/#boolean
File: Property_Boolean.py
TODO: Implement get_payload_from_value to return the lower case strings
I can provide a push request if needed, let me know.
LWT doesn't work because set_will is after connect function . According to MQTT specification LWT can be set only in connection packet. I tested this using mosquitto server.
I'm using the Pimoroni Automation HAT, and I'd like to use its controllable comms
LED to reflect the MQTT connection status.
Is there an easy way to get my code hooked into the connect/disconnect callbacks to update the LED status? I've done this using the paho MQTT library directly, but I don't see a way to do this with your homie library.
Thanks
It is not possible to configure network encryption and authentication options except enabling TLS, see:
Homie4/homie/mqtt/paho_mqtt_client.py
Line 75 in ebe5255
I'd suggest changing that particular line to:
self.mqtt_client.tls_set(**self.mqtt_settings["MQTT_TLS_OPTIONS"])
where MQTT_TLS_OPTIONS
would be a dictionary with corresponding options as part of MQTT_SETTINGS
, see
Homie4/homie/mqtt/homie_mqtt_client.py
Line 12 in ebe5255
MQTT_SETTINGS
could be extended like that:
'MQTT_TLS_OPTIONS' : dict()
A client's MQTT settings could then be configured to use TLS with a CA certificate file by for example:
mqtt_settings = {
'MQTT_BROKER' : 'mybroker',
'MQTT_PORT' : 8883,
'MQTT_USERNAME' : 'test',
'MQTT_PASSWORD' : 'test',
'MQTT_USE_TLS' : True,
'MQTT_TLS_OPTIONS' : dict(
ca_certs = 'ca-root.crt'
)
}
G'day,
I am curious as to what the intent of the status device is?
Do you have an example?
Regards,
Christopher
There is an issue related to Home Asisstant in this line
https://github.com/mjcumming/homie4/blob/35766d84ad1cad524357d172c986a3b3751cff25/homie/device_base.py#L280
self.publish_homeassistant()
TypeError: publish_homeassistant() missing 2 required positional arguments: 'hass_config' and 'hass_payload'
I don't know the purpose of this line. I don't use HA so I removed this line to fix it
Is it possible to do a new release on PyPi?
My devices are suffering from reconnection issues which have been fixed in master.
G'day,
I have been trying to figure out how the library manages disconnects from the MQTT broker.
I have the situation where the client does get disconnected occasionally (long wireless run which sometimes drops) and I have the following messages:
MQTT Unexpected disconnection <paho.mqtt.client.Client object at 0xb62edbd0> None Connection refused - incorrect protocol version
MQTT On Disconnect: Result Code 1
MQTT Unexpected disconnection <paho.mqtt.client.Client object at 0xb62edbd0> None Connection refused - incorrect protocol version
MQTT On Disconnect: Result Code 1
I was trying to diagnose where the reconnect attempts are being carried out in the homie_mqtt_client.py
code, but it isn't clear to me.
Aside from that, it is strange that the error message is "incorrect protocol version" as the version won't have changed between when it was successfully connected to when it reconnects.
Any pointers would be great.
Thanks and regards,
Christopher
Currently there is a bug with Home Assistant that doesn't allow remapping values on payloads and only supports integers for dimming. Does OpenHAB or other systems want this in decimal? If so would it be worth putting in a flag or option to determine format? Looking at Homie Convention, It doesn't look like it would support same property with different formats stored in MQTT.
I currently have this fixed by removing the multiply and divide by 100 lines. Leaving dimming set to use 0-100 instead of 0.0-1.0.
I do feel decimals are better for fractions/percents but I think most home automation only use 0-100 or 0-255 integers for the devices.
Hi,
I'm using MQTT over a network that has other stuff on it, and so have it configured with SSL.
I'll submit a pull request with a (very) rough/simple idea to get this working for the PAHO client shortly...
Dave
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.