I’ve recently installed a SwitchBot on my icemaker, but I’m facing a challenge with monitoring its state. The icemaker’s power supply is controlled by a smart plug, allowing me to monitor its wattage usage. I want to create a custom device integration that updates every X seconds to check the state based on the wattage.
The goal is to have a solution where the state of the icemaker is determined by the wattage it’s using. For instance, if it’s using power, it’s considered on, and if not, it’s considered off.
I’ve thought about creating a custom device that can check the wattage usage and update the state accordingly. However, I’m not sure where to start with this. If it were a switch, I could easily turn it off/on, but I need the state to be controlled by the wattage.
Has anyone here attempted something similar or could guide me on how to create a custom integration for this purpose? Any help, advice, or pointers in the right direction would be greatly appreciated.
Thank you in advance for your assistance!
switch: switch.zolder_switchbot_ijsmachine
powerplug power: sensor.ijsmachine_powerplug_power
yes i could get this one:
switch:
- platform: template
switches:
blind:
friendly_name: "Blind"
value_template: "{{ is_state_attr('switch.blind_toggle', 'sensor_state', 'on') }}"
turn_on:
service: switch.toggle
target:
entity_id: switch.blind_toggle
turn_off:
service: switch.toggle
target:
entity_id: switch.blind_toggle
but i need the wattage as value not just a sensor with boolean
if higher then lets say 5 or 2 its on if its 0 for longer then 10 minutes its off
its a bit hard to really know its on because the power draw isnt all time
Let’s clarify the goal…
What is the purpose of the entity you want to create? Is it to simply indicate the on/off state of the ice maker or to perform some action based on the state?
How does the Switchbot switch come into play? What purpose does it serve regarding the goal of the new entity?
- its a dumb device it has on/off button thats it
- switchbot presses the button
- the powerplug measures the power, it goes around the 100watt if its on but sometimes drops to 0 for a few seconds (when the icecubes are done and it grabs new water)
i want a switch that i can turn on / off (with Homekit) i cannot rely on switchbot because it just presses the button it doesnt know the state.
right now i look at the wattage sensor to see if the device is on or off
switch:
- platform: template
switches:
blind:
friendly_name: "IceMachine"
value_template: "IF sensor.ijsmachine_powerplug_power IS HIGHER THEN 5 THEN SHOW THE STATE AS ON IF sensor.ijsmachine_powerplug_power STATE IS LOWER THEN 5 FOR 1 MINUTE THEN SHOW THE STATE AS OFF"
turn_on:
service: switch.toggle
target:
entity_id: switch.zolder_switchbot_ijsmachine
turn_off:
service: switch.toggle
target:
entity_id: switch.zolder_switchbot_ijsmachine
The the time requirement can be satisfied using either a trigger-based Template binary sensor or a state-based Template binary sensor with delays.
Trigger-based:
template:
- trigger:
- platform: numeric_state
entity_id: sensor.ijsmachine_powerplug_power
below: 5
for: "00:01:00"
id: 'off'
- platform: numeric_state
entity_id: sensor.ijsmachine_powerplug_power
above: 5
id: 'on'
binary_sensor:
- name: Ijsmachine State
state: "{{ trigger.id }}"
availability: "{{ has_value('sensor.ijsmachine_powerplug_power') }}"
Using delay_off
:
template:
- binary_sensor:
- name: Ijsmachine State
state: "{{ states('sensor.ijsmachine_powerplug_power') | float(0) > 5 }}"
delay_off: "00:01:00"
availability: "{{ has_value('sensor.ijsmachine_powerplug_power') }}"
Then your template switch uses that as the source for it’s state:
switch:
- platform: template
switches:
blind:
friendly_name: "IceMachine"
value_template: "{{ states('binary_sensor.ijsmachine_state') }}"
turn_on:
service: switch.toggle
target:
entity_id: switch.zolder_switchbot_ijsmachine
turn_off:
service: switch.toggle
target:
entity_id: switch.zolder_switchbot_ijsmachine
Yup that works!
thank you very much for this lesson