SHAC/MQTT/HomeAssistant recall previous level

Discussion in 'C-Bus Automation Controllers' started by ssaunders, May 1, 2022.

  1. ssaunders

    ssaunders

    Joined:
    Dec 17, 2008
    Messages:
    243
    Likes Received:
    35
    Location:
    Melbourne
    True story. Sensors are one way. The others are bi-directional because they are MQTT integrated in HASS, so any change there results in a topic publish which the SHAC is subscribed to and responds.

    I think Powerwall data direct from SHAC might be more elegant than you think. It's the way I'd do it. Just one resident script.

    If I get a moment I'll give the approach more naval gazing.
     
    Last edited: Nov 7, 2022
    ssaunders, Nov 7, 2022
    #21
  2. ssaunders

    philthedill

    Joined:
    Mar 21, 2010
    Messages:
    143
    Likes Received:
    4
    Location:
    Melbourne
    thanks for clearing that up. there have been many attempts to conquer Tesla Powerwall in HA and only recently did this integration appear - and it works. there are 2 control elements here that it is important to capture. they are "select options". covering operating mode, and backup reserve level + lots of sensors. it is called tesla_custom but I cannot locate it for some reason. there is no rush on this from my perspective now that a viable alternative is in place - thanks to you. others may be keen to see something. Note that the integration also covers Tesla cars
     
    philthedill, Nov 7, 2022
    #22
  3. ssaunders

    ssaunders

    Joined:
    Dec 17, 2008
    Messages:
    243
    Likes Received:
    35
    Location:
    Melbourne
    I haven't got one of those either. Just five BMs with engines that loudly go bang. :D I'll have a look at some LUA for you and others. Given I don't have any of this kit I might call on you for some testing if you're up for it.
     
    ssaunders, Nov 7, 2022
    #23
  4. ssaunders

    philthedill

    Joined:
    Mar 21, 2010
    Messages:
    143
    Likes Received:
    4
    Location:
    Melbourne
    happy to help if I can
     
    philthedill, Nov 7, 2022
    #24
  5. ssaunders

    vworp

    Joined:
    Aug 17, 2005
    Messages:
    18
    Likes Received:
    1
    Location:
    Stoke On Trent, UK
    Phenomenal work! I've finally gotten around to trying Home Assistant this week, so I thought I'd give your scripts a go.
    For the most part, auto discovery works really well, I do seem, to have some issues with bsensors.
    I've got a tag saved as :-
    MQTT, bsensor, pn=Landing PIR, sa=Landing,

    Which I believe should discover as a read only, on off value, but actually generates nothing.

    Log errors are:-
    * string: Warning: Read undeclared global variable "off"
    * string: Warning: Read undeclared global variable "on"
    * string: Error publishing outstanding CBus discovery topics: [string "Resident"]:633: attempt to concatenate global 'on' (a nil value)

    If I change the tag to binarysensor, the device discovers it as a dimmable light



     
    vworp, Feb 9, 2024
    #25
  6. ssaunders

    ssaunders

    Joined:
    Dec 17, 2008
    Messages:
    243
    Likes Received:
    35
    Location:
    Melbourne
    Thanks, @vworp. This is fixed and pushed as part of commit 1459706.

    The keyword for binary sensor type is "binary_sensor". I have added the type without underscore as a synonym to prevent others also falling foul of a simple missing character.
     
    Last edited: Feb 10, 2024
    ssaunders, Feb 10, 2024
    #26
  7. ssaunders

    vworp

    Joined:
    Aug 17, 2005
    Messages:
    18
    Likes Received:
    1
    Location:
    Stoke On Trent, UK
    Thanks.
    I can confirm MQTT, bsensor, pn=Landing PIR, sa=Landing, on=Motion detected, off=No motion, is discovering correctly now.
     
    vworp, Feb 10, 2024
    #27
    ssaunders likes this.
  8. ssaunders

    ssaunders

    Joined:
    Dec 17, 2008
    Messages:
    243
    Likes Received:
    35
    Location:
    Melbourne
    ssaunders, Feb 10, 2024
    #28
  9. ssaunders

    ssaunders

    Joined:
    Dec 17, 2008
    Messages:
    243
    Likes Received:
    35
    Location:
    Melbourne
    I've been thinking about this lately, Michael. How about something simple like this...

    Tag an AC object with something like the below, with "isensor" being an inbound sensor? acMqtt could subscribe to the topic and publish any changes in the user parameter/GA. Should be quite simple to implement I reckon.

    Code:
    MQTT, isensor, topic=mymadeupsensor/value
     
    ssaunders, Apr 25, 2024
    #29
  10. ssaunders

    ssaunders

    Joined:
    Dec 17, 2008
    Messages:
    243
    Likes Received:
    35
    Location:
    Melbourne
    This is done, @philthedill, committed at autoSteve/acMqtt.
     
    ssaunders, Apr 27, 2024
    #30
  11. ssaunders

    daniel C-Busser Moderator

    Joined:
    Jul 26, 2004
    Messages:
    770
    Likes Received:
    21
    Location:
    Adelaide
    Hiya, jumping in at random @ssaunders but using and loving your script at:

    https://github.com/autoSteve/acMqtt/blob/master/MQTT send receive.lua

    Just wanted to mention I hit an error in the error, line 751:
    error('Error: nil channel for name '..str(name)..' at '..net..'/'..app..'/'..group..'... a name is required')

    SS MQTT 20.08.2024 22:30:46
    * string: Warning: Read undeclared global variable "str"
    SS MQTT 20.08.2024 22:30:46
    * string: [string "Resident"]:749: attempt to call global 'str' (a nil value)

    I figure you meant tostring()? Totally minor but just wanted to let you know. Thanks again for the awesome script!
     
    daniel, Aug 20, 2024
    #31
    ssaunders likes this.
  12. ssaunders

    ssaunders

    Joined:
    Dec 17, 2008
    Messages:
    243
    Likes Received:
    35
    Location:
    Melbourne
    Yep. My Python brain inadvertently does this at times to Lua. Thanks Daniel. Fixed.
     
    ssaunders, Aug 24, 2024
    #32
  13. ssaunders

    ssaunders

    Joined:
    Dec 17, 2008
    Messages:
    243
    Likes Received:
    35
    Location:
    Melbourne
    ssaunders, Aug 24, 2024
    #33
  14. ssaunders

    Ambro

    Joined:
    Nov 23, 2010
    Messages:
    110
    Likes Received:
    3
    Location:
    Adelaide
    @ssaunders - Bloody Brilliant. Got this going tonight and I appreciate all your hard work - when I'm next in Melbourne I'll definitively PM you and buy you a few rounds of beer :)

    Now its time to transfer all my PICED coding into HA and kiss goodbye to my CTC...
     
    Ambro, Sep 12, 2024
    #34
    ssaunders likes this.
  15. ssaunders

    Butscut

    Joined:
    Dec 18, 2024
    Messages:
    1
    Likes Received:
    0
    Location:
    Geelong, Victoria, AU
    Having read through this chat, I am concerned that my Wiser 2 CBus system my fall outside of the scope of application for this script.
    @ssaunders Before I attempt to do something that sends me down a deep dark rabbit hole, would you happen to know if the approach described here would work in my "first Gen" (circa 2017) Wiser 2 (5200WHC2) aka Wiser Home Controller 2 - which I understand is different to the later versions of Wiser Home controller.
     
    Butscut, Dec 18, 2024
    #35
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.