GithubHelp home page GithubHelp logo

homie4's People

Contributors

bcopy avatar euphi avatar klaudiusz223 avatar mattange avatar mjcumming avatar patn03 avatar pavog avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

homie4's Issues

Get node id

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

Possible to group basic devices into one device ?

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 ?

Generic example

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.

Logic of Property_Contact inversed?

G'day,

I think the logic of the get_payload_from_value() method in the Property_Contact class is inversed

https://github.com/mjcumming/homie4/blob/8a2d23a1487c8cd378f0e3f594cf2680c34001f0/homie/node/property/property_contact.py#L43

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

Adding a property to an existing device node

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

MQTT last will doesn't work

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.

[question] on_connect on_disconnect callbacks

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

TLS configuration

It is not possible to configure network encryption and authentication options except enabling TLS, see:

self.mqtt_client.tls_set()

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

MQTT_SETTINGS = {

So the initialiszation of 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'
    )
}

PyPi out of date

Is it possible to do a new release on PyPi?
My devices are suffering from reconnection issues which have been fixed in master.

[question] MQTT reconnect - how does that work?

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

Dimmer Percent as Decimal(Float) to support INT

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.

https://github.com/mjcumming/homie4/blob/6338938c59e56d8ade4162bf23a75fa43405ab6a/homie/node/property/property_dimmer.py#L42

https://github.com/mjcumming/homie4/blob/6338938c59e56d8ade4162bf23a75fa43405ab6a/homie/node/property/property_dimmer.py#L48

SSL/TLS not supported

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.