Last active
June 11, 2023 08:50
-
-
Save ThePrincelle/afaa3bd3e74aacb9101b7d70e5f939fc to your computer and use it in GitHub Desktop.
Script pour échange HA <> eedomus
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# eedomus_command.py | |
import requests | |
api_user = "XXXXXX" | |
api_secret = "XXXXXXXXXXXXXXXX" | |
action = "periph.value" | |
@service | |
def eedomus_command(periph_id=None, value=None): | |
"""yaml | |
description: sends value to periph on eedomus | |
fields: | |
periph_id: | |
description: periph_id of the device to control | |
example: 223453 | |
value: | |
description: value to be sent to the periph | |
example: 100 | |
""" | |
#url = "http://192.168.0.13/api/set" | |
#payload = {'api_user': api_user, 'api_secret': api_secret, 'action': action, 'periph_id': periph_id, 'value': value} | |
url = "http://192.168.0.13/script/?exec=set_value.php" | |
payload = {'id': periph_id, 'val': value} | |
r = task.executor(requests.get, url, params=payload, timeout=5) | |
#print(r.url) | |
#print(r.raw) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# eedomus | |
- platform: rest | |
name: eedomus_states | |
resource: http://192.168.0.13/script/?exec=get_values.php&ids=35556,242823,263626,258976 | |
json_attributes_path: "$.response" | |
scan_interval: 5 | |
value_template: 'OK' | |
json_attributes: | |
- "id_181853" | |
- "id_125901" | |
- "id_193455" | |
- "id_39631" | |
- "id_242086" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- platform: template | |
covers: | |
volet_sejour_est: | |
device_class: shutter | |
friendly_name: "Volet Séjour Est" | |
position_template: "{{ states.sensor.eedomus_states.attributes.id_242823 | int }}" | |
open_cover: | |
service: pyscript.eedomus_command | |
data_template: | |
periph_id: "242823" | |
value: "100" | |
close_cover: | |
service: pyscript.eedomus_command | |
data_template: | |
periph_id: "242823" | |
value: "0" | |
stop_cover: | |
service: pyscript.eedomus_command | |
data_template: | |
periph_id: "242823" | |
value: "240" | |
set_cover_position: | |
service: pyscript.eedomus_command | |
data_template: | |
periph_id: "242823" | |
value: "{{position}}" | |
volet_terrasse_est: | |
device_class: shutter | |
friendly_name: "Volet Terrasse Est" | |
position_template: "{{ states.sensor.eedomus_states.attributes.id_258976 | int }}" | |
open_cover: | |
service: pyscript.eedomus_command | |
data_template: | |
periph_id: "258976" | |
value: "100" | |
close_cover: | |
service: pyscript.eedomus_command | |
data_template: | |
periph_id: "258976" | |
value: "0" | |
stop_cover: | |
service: pyscript.eedomus_command | |
data_template: | |
periph_id: "258976" | |
value: "240" | |
set_cover_position: | |
service: pyscript.eedomus_command | |
data_template: | |
periph_id: "258976" | |
value: "{{position}}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# eedomus | |
- platform: template | |
lights: | |
spots_chb_parentale: | |
friendly_name: "Spots Chb. Parentale" | |
value_template: "{{ (states.sensor.eedomus_states.attributes.id_421691 | int) > 0 }}" | |
level_template: "{{ (states.sensor.eedomus_states.attributes.id_421691 | float * 2.55) | round(0)}}" | |
turn_on: | |
service: pyscript.eedomus_command | |
data_template: | |
periph_id: "421691" | |
value: "100" | |
turn_off: | |
service: pyscript.eedomus_command | |
data_template: | |
periph_id: "421691" | |
value: "0" | |
set_level: | |
service: pyscript.eedomus_command | |
data_template: | |
periph_id: "421691" | |
value: "{{ ((brightness | float / 255 ) * 100) }}" | |
lampadaire: | |
friendly_name: "Lampadaire" | |
value_template: "{{ states.sensor.eedomus_states.attributes.id_942600 == '100' }}" | |
turn_on: | |
service: pyscript.eedomus_command | |
data_template: | |
periph_id: "942600" | |
value: "100" | |
turn_off: | |
service: pyscript.eedomus_command | |
data_template: | |
periph_id: "942600" | |
value: "0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- platform: template | |
switches: | |
vmc_principale: | |
friendly_name: "VMC Principale" | |
value_template: "{{ states.sensor.eedomus_states.attributes.id_60542 == '100' }}" | |
turn_on: | |
service: pyscript.eedomus_command | |
data_template: | |
periph_id: "60542" | |
value: "100" | |
turn_off: | |
service: pyscript.eedomus_command | |
data_template: | |
periph_id: "60542" | |
value: "0" | |
prise_interface_velux: | |
friendly_name: "Prise Interface Velux" | |
value_template: "{{ states.sensor.eedomus_states.attributes.id_762318 == '100' }}" | |
turn_on: | |
service: pyscript.eedomus_command | |
data_template: | |
periph_id: "762318" | |
value: "100" | |
turn_off: | |
service: pyscript.eedomus_command | |
data_template: | |
periph_id: "762318" | |
value: "0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
////////////////////////// | |
// get_values.php // | |
// by Maxime Princelle // | |
////////////////////////// | |
///////////////////////// | |
//Recuperation des ids | |
$ids = explode(",", $_GET["ids"]); | |
///////////////////////// | |
//Recuperation des valeurs | |
$values = array(); | |
foreach ($ids as $id) { | |
// echo($id + "<br/>"); | |
$value = getValue($id, false); | |
$temp_array = array(array($id, $value["value"])); | |
$values = array_merge($values, $temp_array); | |
} | |
///////////////////////// | |
//Reponse | |
$xml = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><response>"; | |
foreach($values as $val) | |
{ | |
$xml .= '<id_' . $val[0] . '>' . $val[1] . '</id_' . $val[0] . '>'; | |
} | |
$xml .= "</response>"; | |
header('Content-type: text/xml'); | |
echo $xml | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
////////////////////////// | |
// send_ha_event.php // | |
// by Maxime Princelle // | |
////////////////////////// | |
$token = "xxx"; | |
$auth = "Authorization: Bearer " . $token; | |
$url = "http://192.168.0.75:8123/api/events/" . getArg("event"); | |
httpQuery($url, "POST", $post = NULL, $oauth_token=NULL, $headers=array($auth), $use_cookies=false, $ignore_errors=false, $info, $user_pwd=NULL); | |
echo "Event sent to HA." | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
////////////////////////// | |
// set_value.php // | |
// by Maxime Princelle // | |
////////////////////////// | |
$id = getArg('id', $mandatory = true); | |
$val = getArg('val', $mandatory = true); | |
setValue($periph_id=$id, $value=$val, $verify_value_list = false); | |
echo("Setting periph: " + $id + " to value: " + $val); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- platform: template | |
sensors: | |
sonde_cave_vins: | |
friendly_name: "Sonde Cave à Vins" | |
value_template: '{{ states.sensor.eedomus_states.attributes["id_39636"] }}' | |
unit_of_measurement: '°C' | |
device_class: temperature | |
sonde_congelateur: | |
friendly_name: "Sonde Congélateur" | |
value_template: '{{ states.sensor.eedomus_states.attributes["id_39634"] }}' | |
unit_of_measurement: '°C' | |
device_class: temperature |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment