Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- greentel:
- sensor:
- - platform: template
- sensors:
- talktime:
- friendly_name: "Taletid"
- entity_id: sensor.greentel_status
- unit_of_measurement: "%"
- value_template: >-
- {{ ( ( (state_attr("sensor.greentel_status", "Tale") | replace(',', '.') | float ) / (state_attr("sensor.greentel_status", "Tale_MAX") | replace(',', '.') | float ) ) * 100 ) | round }}
- icon_template: mdi:phone-in-talk
- attribute_templates:
- used: >-
- {{ state_attr("sensor.greentel_status", "Tale") }}
- total: >-
- {{ state_attr("sensor.greentel_status", "Tale_MAX") }}
- - platform: template
- sensors:
- data:
- friendly_name: "Data"
- entity_id: sensor.greentel_status
- unit_of_measurement: "%"
- value_template: >-
- {{ ( ( (state_attr("sensor.greentel_status", "Data") | replace(',', '.') | float ) / (state_attr("sensor.greentel_status", "Data_MAX") | replace(',', '.') | float ) ) * 100 ) | round }}
- icon_template: mdi:signal-cellular-3
- attribute_templates:
- used: >-
- {{ state_attr("sensor.greentel_status", "Data") }}
- total: >-
- {{ state_attr("sensor.greentel_status", "Data_MAX") }}
- - platform: template
- sensors:
- text:
- friendly_name: "SMS"
- entity_id: sensor.greentel_status
- unit_of_measurement: "%"
- value_template: >-
- {{ ( ( (state_attr("sensor.greentel_status", "SMS") | replace(',', '.') | float ) / (state_attr("sensor.greentel_status", "SMS_MAX") | replace(',', '.') | float ) ) * 100 ) | round }}
- icon_template: cellphone-text
- attribute_templates:
- used: >-
- {{ state_attr("sensor.greentel_status", "SMS") }}
- total: >-
- {{ state_attr("sensor.greentel_status", "SMS_MAX") }}
- - platform: template
- sensors:
- data_modem:
- friendly_name: "Modem"
- entity_id: sensor.greentel_status
- unit_of_measurement: "%"
- value_template: >-
- {{ ( ( (state_attr("sensor.greentel_status", "Data_Modem") | replace(',', '.') | float ) / (state_attr("sensor.greentel_status", "Data_Modem_MAX") | replace(',', '.') | float ) ) * 100 ) | round }}
- icon_template: mdi:signal-4g
- attribute_templates:
- used: >-
- {{ state_attr("sensor.greentel_status", "Data_Modem") }}
- total: >-
- {{ state_attr("sensor.greentel_status", "Data_Modem_MAX") }}
- shell_command:
- # Følgende skal ændres i kommandoerne
- # PARSEHUB_PROJECT_TOKEN
- # PARSEHUB_API_TOKEN
- # HA_API_TOKEN
- # HA_URL
- greentel_scrape: 'curl -X POST -d "api_key=PARSEHUB_API_TOKEN" "https://www.parsehub.com/api/v2/projects/PARSEHUB_PROJECT_TOKEN/run"'
- greentel_get: 'rm -f greentel.json; curl -X GET "https://www.parsehub.com/api/v2/projects/PARSEHUB_PROJECT_TOKEN/last_ready_run/data?api_key=PARSEHUB_API_TOKEN" | gunzip > greentel.json; curl -X POST -H "Accept: application/json" -H "Authorization: Bearer HA_API_TOKEN" -H "Content-Type: application/json" -d "{\"state\": \"$(date +%s)\", \"attributes\": $(cat greentel.json)}" http://HA_URL/api/states/sensor.greentel_status; rm -f greentel.json'
- automation:
- - alias: "Greentel hent værdier"
- trigger:
- - platform: homeassistant
- event: start
- - platform: time
- at: "04:20:00"
- action:
- - service: shell_command.greentel_get
- - alias: "Greentel scrape"
- trigger:
- - platform: time
- at: "04:00:00"
- action:
- - service: shell_command.greentel_scrape
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement