41 lines
1.5 KiB
YAML
41 lines
1.5 KiB
YAML
- sensor:
|
|
name: Sonos_Sleep_Timer
|
|
command: |
|
|
curl -X POST "http://10.0.3.33:1400/MediaRenderer/AVTransport/Control" \
|
|
-H "Content-Type: text/xml; charset=utf-8" \
|
|
-H "SOAPAction: urn:schemas-upnp-org:service:AVTransport:1#GetRemainingSleepTimerDuration" \
|
|
--data '<?xml version="1.0"?>
|
|
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
|
|
<s:Body>
|
|
<u:GetRemainingSleepTimerDuration xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">
|
|
<InstanceID>0</InstanceID>
|
|
</u:GetRemainingSleepTimerDuration>
|
|
</s:Body>
|
|
</s:Envelope>'
|
|
value_template: >
|
|
{% set result = value | regex_findall('<RemainingSleepTimerDuration>([\d:]+)</RemainingSleepTimerDuration>') %}
|
|
{% if result and result[0] %}
|
|
{% set time_str = result[0] %}
|
|
{% set time_parts = time_str.split(':') %}
|
|
{% set hours = time_parts[0]|int %}
|
|
{% set minutes = time_parts[1]|int %}
|
|
{% set total_minutes = (hours * 60) + minutes %}
|
|
{{ total_minutes }}
|
|
{% else %}
|
|
0
|
|
{% endif %}
|
|
scan_interval: 60
|
|
|
|
|
|
- sensor:
|
|
name: vecka_jobb
|
|
unique_id: vecka_jobb_sensor
|
|
command: "cat /config/files/week.json"
|
|
scan_interval: 300
|
|
value_template: "ok"
|
|
json_attributes: # Lagra JSON-data som attribut
|
|
- monday
|
|
- tuesday
|
|
- wednesday
|
|
- thursday
|
|
- friday |