Home Assistant : Q&A, Tips & Tricks, Your Configs

Speedster

Honorary Master
Joined
May 2, 2006
Messages
18,681
I recommend a mini pc over a Pi.

Go here: https://www.takealot.com/computers/mini-pc-27164?sort=Price Ascending

Choose one that fit your budget best, however if you can, try at minimum to get the Intel NUC.

You will thank me later, when it just works with HA without SD cards corrupting etc. By the time you have a SSD on your Pi and got over the Pi stock availability issues, not to mention all the additional stuff like power adapter case, etc you need just to turn it on, you might as well have paid for the NUC.
There are quite a few NUCs floating around on Facebook Marketplace. I picked up an older Celeron based NUC for about R1000 about a year ago and haven't had a day's issue.

Running HA, plex, Adguard and some other apps on it and the Celeron has plenty juice for those.
 

rrh

Expert Member
Joined
Nov 29, 2005
Messages
4,031
There are quite a few NUCs floating around on Facebook Marketplace. I picked up an older Celeron based NUC for about R1000 about a year ago and haven't had a day's issue.

Running HA, plex, Adguard and some other apps on it and the Celeron has plenty juice for those.
Ditto eBay.
 

w1tw0lf

Expert Member
Joined
Sep 29, 2009
Messages
1,093
You have 2 options.

1. (expensive) buy envisalink and use envisalink integration
2. (cheaper) use an ESP8266 with ESPHome that you build: https://github.com/Dilbert66/esphome-dsckeybus
Also running 2. On friday switch to esp32 as esp8266 has a limitation with memory.

Playing with the new branch and one thing I do like about it as if loadshedding comes around it sets the time on the panel. Need to replace alarm battery as it does last long. Also a few other new few other new features. Just keep in mind it is alpha version.
 

Mzezman

Expert Member
Joined
Nov 13, 2021
Messages
1,277
What do you guys do for the windows restart for updates?
HA also has to restart when you upgrade it etc so its much of a muchness. Previously I was running mine on a Windows PC in a VM and had the VM boot as soon as Windows restarted... never had issues. I might actually move back to a VM from the Pi if I can upgrade my processor to an i7 (same machine is running Plex, Blue Iris and the *arr suite)
 

Mzezman

Expert Member
Joined
Nov 13, 2021
Messages
1,277
What do you guys do for the windows restart for updates?
HA also has to restart when you upgrade it etc so its much of a muchness. Previously I was running mine on a Windows PC in a VM and had the VM boot as soon as Windows restarted... never had issues. I might actually move back to a VM from the Pi if I can upgrade my processor to an i7 (same machine is running Plex, Blue Iris, Unifi Controller and the *arr suite)
 

cschutte

Active Member
Joined
Aug 1, 2007
Messages
65
Does anybody have a way to get the current load shedding stage for City of Cape Town as a value in an entity, or as an input in a Node Red automation, to determine the next load shedding event?

I am currently using Node Red as per https://github.com/dalehumby/Eskom-Loadshedding-NodeRED but this uses the Eskom Loadshedding Stage as input to get the next load shedding event, but City of CapeTown is often (but not always) a stage less.
 

cschutte

Active Member
Joined
Aug 1, 2007
Messages
65
Well I think I got the logic right for my very 1st loadshedding slot work-around to....work.

I started with the pool pump, and will later today also do it for some of my other timers like the geysers.

So I have a loadshedding.yaml package with the following:
Code:
input_number:
  loadshedding_stage_eskom:
    name: Eskom Loadshedding Stage
    min: -100
    max: 8
  loadshedding_stage_coct:
    name: CoCT Loadshedding Stage
    min: -100
    max: 8
input_boolean:
  loadshedding_slot_active:
    name: Loadshedding slot active
timer:
  loadshedding_slot:
    duration: '02:35:00'
automation:
  - alias: start_loadshedding_slot_timer
    trigger:
      - platform: state
        entity_id: input_boolean.loadshedding_slot_active
        to: 'on'
      - platform: numeric_state
        entity_id: input_number.loadshedding_stage_coct
        above: 0
    condition:
      # make sure timer not already active
      - condition: state
        entity_id: timer.loadshedding_slot
        state: 'idle'
      # check conditions for both tiggers
      - condition: state
        entity_id: input_boolean.loadshedding_slot_active
        state: 'on'
      - condition: numeric_state
        entity_id: input_number.loadshedding_stage_coct
        above: 0
    action:
      - service: timer.start
        data:
          entity_id: timer.loadshedding_slot

Node-red manages the 3 inputs. Sometimes it gets CoCT's loadshedding level correct, if not it will be the same as eskom. Loadshedding slot active can be used, but my other automations will be based on events from the timer.

Anyways, so here is what my pool pump package look like now:
Code:
input_datetime:
  pool_pump_on_time:
    name: Pool pump on time
    has_date: false
    has_time: true
timer:
  pool_pump:
    name: Pool pump
    duration: '03:00:00'
automation:
  # Pool pump on based on input time
  - alias: Turn on pool pump
    trigger:
      platform: template
      value_template: "{{ states('sensor.time') == (state_attr('input_datetime.pool_pump_on_time', 'timestamp') | int | timestamp_custom('%H:%M', False)) }}"
    condition:
      - condition: state
        entity_id: timer.loadshedding_slot
        state: 'idle'
    action:
    - service: switch.turn_on
      data:
        entity_id: switch.pool_pump
    - service: timer.start
      data_template:
        entity_id: timer.pool_pump
        duration: >
          {% set day_names = [ 'monday', 'tuesday', 'wednesday','thursday','friday','saturday','sunday'] %}
          {% set today_name = day_names[now().weekday()] %}
          {% if today_name == 'sunday' %}{{ 300 | int * 60 }}
          {% else %}{{ 300 | int * 60 }}{% endif -%}
  # pool pump off when timer finish
  - alias: Turn off pool pump
    trigger:
      - platform: event
        event_type: timer.finished
        event_data:
          entity_id: timer.pool_pump
    action:
      - service: switch.turn_off
        data:
          entity_id: switch.pool_pump

  # Loadshedding work-arounds
  # When in loadshedding, start timer and pause
  - alias: Turn on pool pump timer in loadshedding
    trigger:
      platform: template
      value_template: "{{ states('sensor.time') == (state_attr('input_datetime.pool_pump_on_time', 'timestamp') | int | timestamp_custom('%H:%M', False)) }}"
    condition:
      - condition: state
        entity_id: timer.loadshedding_slot
        state: 'active'
    action:
    - service: timer.start
      data_template:
        entity_id: timer.pool_pump
        duration: >
          {% set day_names = [ 'monday', 'tuesday', 'wednesday','thursday','friday','saturday','sunday'] %}
          {% set today_name = day_names[now().weekday()] %}
          {% if today_name == 'sunday' %}{{ 300 | int * 60 }}
          {% else %}{{ 300 | int * 60 }}{% endif -%}
    # Waits 1 seconds
    - delay: '00:00:01'
    - service: timer.pause
      data_template:
        entity_id: timer.pool_pump
  # Resume pool pump after loadshedding finished
  - alias: Turn on pool pump after loadshedding slot ended
    trigger:
      - platform: event
        event_type: timer.finished
        event_data:
          entity_id: timer.loadshedding_slot
    condition:
      - condition: state
        entity_id: timer.pool_pump
        state: 'paused'
    action:
      # Starts or restarts a timer with the provided duration.
      # If no duration is given, it will either restart with its initial
      # value, or continue a paused timer with the remaining duration.
      - service: timer.start
        data:
          entity_id: timer.pool_pump
      - service: switch.turn_on
        data:
          entity_id: switch.pool_pump
  # Pause pool pump if loadshedding slot started
  - alias: Pause pool pump if loadshedding slot started
    trigger:
      - platform: event
        event_type: timer.started
        event_data:
          entity_id: timer.loadshedding_slot
    condition:
      - condition: state
        entity_id: timer.pool_pump
        state: 'active'
    action:
      - service: timer.pause
        data:
          entity_id: timer.pool_pump
      - service: switch.turn_off
        data:
          entity_id: switch.pool_pump

Maybe it can help someone else who also needs to do this, or even better yet, tell me how to do it better!
Tinuva- This is an old post, but do you perhaps have an export of the NodeRed flow that integrates with loadshedding.yaml package. In your text above: "Node-red manages the 3 inputs. Sometimes it gets CoCT's loadshedding level correct, if not it will be the same as eskom." If possible, I want to see how you determine the COCT Loadshedding Stage.
 

Tinuva

The Magician
Joined
Feb 10, 2005
Messages
11,537
Tinuva- This is an old post, but do you perhaps have an export of the NodeRed flow that integrates with loadshedding.yaml package. In your text above: "Node-red manages the 3 inputs. Sometimes it gets CoCT's loadshedding level correct, if not it will be the same as eskom." If possible, I want to see how you determine the COCT Loadshedding Stage.
I abondonded that, it was from another loadshedding app/website which stopped working. Sorry I don't have better news on this
 

SauRoNZA

Honorary Master
Joined
Jul 6, 2010
Messages
44,678
any MQTT experts that can help me please. I have flashed a 2 Channel Relay with Tasmota and now want to use the GPIO14 with a door contact to read the status of the gate.

I have seen some videos on the MQTT topics but don't think they apply to my config since I have 2 relays and want to use the GPOI14 as switch.

any one that can help with the correct MQTT setting to make sure the switch is separate from the relays? and what the config will look like to add it on a card. Already have the 2 Relays sorted and in HA.

78216f9747ca20ea8db923d2b2dd8cc2.jpg

eeb0b8fa2a7c824dc573f4b36eb05142.jpg


Should sort up you out mostly.

Just need to set the topics on Tasmota which I don’t remember off hand.
 

n00bster

Well-Known Member
Joined
Nov 25, 2008
Messages
170
I have done the topics in Tasmota already thanks a million.

Quick questions.

the topic for the 2 relays are POWER1 and POWER2 so i think the switch will be POWER

so that state topic needs to change as well correct? and then I am not sure about the availability topic? "tasmota_0299AC" is that just the device name I replace. so it should look like the below maybe? if I add it as a sensor it does not work seems like only "Switch" works

Edit: Actually the below does not work. getting error "Switch integration not found" same if I use "cover"
Edit2: okay cover works I had a blond moment. do you have any other config in groups or in the customize

Code:
Switch:
  - platform: mqtt
    Name: "Gate_Status"
    state_topic: cmd/gatestatus/POWER
    command_topic: cmd/gatestatus/POWER
    availability_topic: cmd/gatestatus/LWT
    payload_open: "ON"
    payload_close: "ON"
    payload_stop: "ON"
    state_open: "OPEN"
    state_closed: "CLOSED"
    payload_available: "Online"
    payload_not_available: "Offline"
    optimistic: false
    retain: false
 
Last edited:

Mzezman

Expert Member
Joined
Nov 13, 2021
Messages
1,277
I have done the topics in Tasmota already thanks a million.

Quick questions.

the topic for the 2 relays are POWER1 and POWER2 so i think the switch will be POWER

so that state topic needs to change as well correct? and then I am not sure about the availability topic? "tasmota_0299AC" is that just the device name I replace. so it should look like the below maybe? if I add it as a sensor it does not work seems like only "Switch" works

Edit: Actually the below does not work. getting error "Switch integration not found" same if I use "cover"

Code:
Switch:
  - platform: mqtt
    Name: "Gate_Status"
    state_topic: cmd/gatestatus/POWER
    command_topic: cmd/gatestatus/POWER
    availability_topic: cmd/gatestatus/LWT
    payload_open: "ON"
    payload_close: "ON"
    payload_stop: "ON"
    state_open: "OPEN"
    state_closed: "CLOSED"
    payload_available: "Online"
    payload_not_available: "Offline"
    optimistic: false
    retain: false
shouldnt 'switch' be lowercase? and shouldnt the topics be in " ", e.g.:

Code:
switch:
  - platform: mqtt
    Name: "Gate_Status"
    state_topic: "cmd/gatestatus/POWER"
 

n00bster

Well-Known Member
Joined
Nov 25, 2008
Messages
170
what I am not sure about is the state_topic (POWER2) and command topic (POWER)? that @SauRoNZA has in his posted code.

state_topic is when you want the state of this cover to show that of the POWER2 topic correct? Meaning State of this cover = state of the POWER2

I want it to function on its own since it is a door contact it has its own topic of POWER, that is setup in the tasmota console.

so my code should be right?
 

Tinuva

The Magician
Joined
Feb 10, 2005
Messages
11,537
what I am not sure about is the state_topic (POWER2) and command topic (POWER)? that @SauRoNZA has in his posted code.

state_topic is when you want the state of this cover to show that of the POWER2 topic correct? Meaning State of this cover = state of the POWER2

I want it to function on its own since it is a door contact it has its own topic of POWER, that is setup in the tasmota console.

so my code should be right?
Yeah you need 2 different mqtt devices, even if it is 1 physical device, it is 2 different logical devices in home assistant.

The only time you combine it into 1, is if you use a cover instead of a switch
 

n00bster

Well-Known Member
Joined
Nov 25, 2008
Messages
170
okay so then it needs to be a switch because I do not want to combine it.

I have already decoupled the GPIO14 (switch 2) on the tasmota console.

I now just need to get the switch into HA.
 

Tinuva

The Magician
Joined
Feb 10, 2005
Messages
11,537
okay so then it needs to be a switch because I do not want to combine it.

I have already decoupled the GPIO14 (switch 2) on the tasmota console.

I now just need to get the switch into HA.
Why not a mqtt sensor? It doesnt need to be a switch. Sensor is all you need to know the state.

Actually why not just a cover? A cover is what you want. It will look like a gate in HA and work like a gate and you can open/close on the switch and see state on the 2nd part.
 

Tinuva

The Magician
Joined
Feb 10, 2005
Messages
11,537
@n00bster

See this:
YAML:
cover:
  # Front property gate
  - platform: mqtt
    device_class: gate
    state_topic: "stat/front-gate/POWER2"              #SwitchTopic Enabled
    command_topic: "cmnd/front-gate/POWER1"
    availability_topic: "tele/front-gate/LWT"
    name: "Front Gate"
    qos: 0
    retain: false
    payload_open: "ON"
    payload_close: "ON"
    payload_stop: "ON"
    state_open: "ON"
    state_closed: "OFF"
    payload_available: "Online"
    payload_not_available: "Offline"
 
Top