Is it possible to use the sensor to trigger in an out of bed automations?
Will this work without webhooks? My network is not reachable from the outside and I guess this would be needed for webhooks.
Is it possible to use the sensor to trigger in an out of bed automations?
Will this work without webhooks? My network is not reachable from the outside and I guess this would be needed for webhooks.
The withings in-bed detection is relyant on webhooks, and with the current integration I couldn’t get it to work anyway. I finally used IFTTT as a workaround, but that is not an option if Home Assistant is not exposed to the outside world. I use Nabu Casa cloud for that.
So, there is no way to get that data locally?
There might be another solution, though:
I read that the integration polls every 10 minutes for the state if no webhook is available.
If this time could be shortened in times I might actually go to sleep/wake up it would be perfect.
For example if at home, trigger every minute in the evening and in the morning. I usually don’t sleep at day, so I don’t have to poll.
No, every sensor works, but the in_bed sensor remains unavailable. It is not updated though polling. Also, if you poll too much, the Withings service may hit a rate control limit. As far as I know there is no local API, only though the Withings cloud service.
Withings does state that the sleepmat goes off wifi if you’re on it, so maybe checking it’s IP is possible, but I haven’t tried and I do not know if it is online all the time when you’re not in bed either.
I recently bought a Sleep Analyzer to detect if I am in bed or not. Like Edwin I had no success with the Withings integration in HA and used IFTTT instead. The problem is that it takes around 15-20 secs to update the state (in or not in bed). I think the delay comes from the sensor itself and not IFTTT.
Like Edwin suggested you may could check if the mat is connected to your LAN in order to check its state.
Is anyone else having the same experience with the delay?
I was recently able to get the webhook set-up working (even without Nabu Casa), find more details here: Struggling to get Withings integrations fully operational - #18 by wilcymay
I created a bed precense sensor from other sensors that the withings sleep analyser gives me as sensors. Setting up was a breeze and use this for my sleep alarm triggers etc…
- platform: template
sensors:
bed_presence:
friendly_name: "Bed Presence"
value_template: >-
{% if states('sensor.withings_deep_sleep')|float == 0 or states('sensor.withings_light_sleep')|float == 0 %}
In Bed
{% else %}
Out of Bed
{% endif %}
icon_template: >-
{% if states('sensor.withings_deep_sleep')|float == 0 or states('sensor.withings_light_sleep')|float == 0 %}
mdi:bed-empty
{% else %}
mdi:bed
{% endif %}
availability_template: >-
{{ states('sensor.withings_deep_sleep') not in ['unknown','unavailable'] }}
This is my automation that happens when i go sleeping. But it is pretty complex and not usefull for eveyone. This automation triggers when motion is detected in the bedroom and waits until you’re in bed to start a bedtime routine with actions like dimming lights, setting the alarm, and adjusting the climate in the bedroom.
alias: Alarm - Arm Slapen (Verbetering)
description: ""
triggers:
- type: motion
device_id: 25f786d6d9adde077aa6274293af2db4
entity_id: binary_sensor.bewegingssensor_slaapkamer_motion
domain: binary_sensor
trigger: device
conditions:
- condition: time
after: "21:00:00"
before: "02:00:00"
- condition: state
entity_id: switch.adaptive_lighting_sleep_mode_default
state: "off"
- condition: state
entity_id: input_boolean.aanwezig
state: "on"
- condition: state
entity_id: input_boolean.bezoekersmode
state: "off"
- condition: state
entity_id: input_boolean.net_thuis
state: "off"
- condition: numeric_state
entity_id: sensor.switch_pc_current_consumption
below: 20
- condition: state
entity_id: input_boolean.net_slapen
state: "off"
actions:
- data:
volume_level: 0.2
target:
entity_id: media_player.slaapkamer
action: media_player.volume_set
- data:
entity_id: media_player.slaapkamer
message: Slaapwel, Alarm wordt ingeschakeld binnen 15 minuten
action: tts.cloud_say
- target:
entity_id: input_boolean.net_slapen
data: {}
action: input_boolean.turn_on
- data:
brightness: 255
rgb_color:
- 255
- 147
- 41
action: light.turn_on
target:
entity_id:
- light.lamp_slaapkamer
- light.tafellamp_slaapkamer
- data:
temperature: 15
time_period: "1:00:00"
target:
device_id: cc4136805d8c8149fe8feec4297bab44
enabled: true
action: tado.set_climate_timer
- data: {}
target:
device_id: 0310e157837a7eec45a98089e706f4fb
action: media_player.turn_off
- if:
- type: is_temperature
condition: device
device_id: cc4136805d8c8149fe8feec4297bab44
entity_id: sensor.verwarming_slaapkamer_temperature
domain: sensor
below: 16
- condition: numeric_state
entity_id: sensor.buienradar_temperature
below: 10
then:
- type: turn_on
device_id: 33572bc7db6b48656ebbe43f079e1372
entity_id: f539dd1c4f822270aec1fa74a49b49c9
domain: switch
- data: {}
target:
entity_id:
- input_boolean.koken
- input_boolean.tuin_tuinhuis
- input_boolean.baden_douchen
action: input_boolean.turn_off
- wait_for_trigger:
- entity_id:
- binary_sensor.slaapkamer_bewegingssensors
to: "off"
for:
hours: 0
minutes: 2
seconds: 0
trigger: state
enabled: false
- trigger: state
entity_id:
- sensor.bed_presence
to: In Bed
for:
hours: 0
minutes: 0
seconds: 30
- data:
brightness: 255
rgb_color:
- 255
- 147
- 41
transition: 60
action: light.turn_on
target:
entity_id:
- light.lamp_slaapkamer
- light.tafellamp_slaapkamer
- delay:
minutes: 1
- repeat:
count: 10
sequence:
- target:
entity_id:
- light.lamp_slaapkamer
- light.tafellamp_slaapkamer
data:
brightness: |
{{ (255 - (repeat.index * 10)) | int }}
rgb_color: |
{{ [
max((255 - (repeat.index * 14)) | int, 120),
max((147 - (repeat.index * 12)) | int, 27),
max((41 - (repeat.index * 4)) | int, 0)
] }}
transition: 60
action: light.turn_on
- delay:
minutes: 1
- repeat:
count: 5
sequence:
- target:
entity_id:
- light.lamp_slaapkamer
- light.tafellamp_slaapkamer
data:
brightness: >
{{ max((brightness | default(255) - (repeat.index * 31)) | int, 0)
}}
transition: 60
action: light.turn_on
- delay:
minutes: 1
- delay:
minutes: 1
- target:
entity_id:
- light.lamp_slaapkamer
- light.tafellamp_slaapkamer
action: light.turn_off
data: {}
- target:
entity_id: alarm_control_panel.thuisalarm
data: {}
action: alarm_control_panel.alarm_arm_away
- data: {}
target:
entity_id: switch.adaptive_lighting_sleep_mode_default
action: switch.turn_on
- metadata: {}
data: {}
target:
entity_id: input_boolean.net_slapen
action: input_boolean.turn_off
- data: {}
target:
entity_id:
- automation.heu_color_alarm
- automation.alarm_trigger_lampen_sirene
- automation.new_automationalarm_trigger_lampen
- automation.alarm_trigger_sound
- automation.wake_up_alarm_with_music
- automation.wake_up_light_alarm_with_sunrise_effect
action: automation.turn_on
- data: {}
target:
entity_id: script.music_alarm_volume_adjust
action: script.turn_on
- data: {}
target:
device_id:
- d8b798639261470c4a11369d8962ef40
- 30dadd1eb7a3645de4341e10b22eda49
- 4e60105b6e1aad425592f96c133ffa5b
- 13124f988b62632ca326737a6c4d22d2
- 37261380c8faffc874808ac4c496f1b3
- 09224e9eec220f7e4ebe880f8d1aaf39
- 64dac98bf6970eb809b55f0f4af2466e
- 494ff120bfb25322f649c38e30bf55aa
- 25c9c319a00f29ee23f25f2a77cf6e42
entity_id:
- switch.switch_slaapkamer_tv
- switch.switch_slaapkamer_surround
- switch.switch_slaapkamer_speaker
action: switch.turn_off
- data:
transition: 5
target:
area_id:
- gang
- bureau
- woonkamer
- badkamer
- eetkamer
- keuken
- tuin
- tuinhuis
- berging
- gangetje
- logeerkamer
- kelder
- wc
action: light.turn_off
mode: single