Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/translations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: translate

on:
workflow_dispatch:
push:
branches:
- beta

jobs:
auto-translate:
runs-on: ubuntu-latest
steps:
- uses: jeedom/jeetranslate@main
with:
deepl_api_key: ${{ secrets.DEEPL_API_KEY }}
include_empty_translation: false
target_languages: "en_US,es_ES,de_DE,it_IT,pt_PT"
use_core_translations: true
4 changes: 3 additions & 1 deletion core/class/ash.class.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
include_file('core', 'ash_PowerLevelController', 'class', 'ash');
include_file('core', 'ash_ToggleController', 'class', 'ash');
include_file('core', 'ash_LockController', 'class', 'ash');
include_file('core', 'ash_GarageDoorController', 'class', 'ash');

class ash extends eqLogic {

Expand Down Expand Up @@ -68,7 +69,7 @@ public static function getSupportedType() {
'DOOR' => array('name' => __('Porte', __FILE__), 'skills' => array('ContactSensor', 'LockController')),
'EXTERIOR_BLIND' => array('name' => __('Volet', __FILE__), 'skills' => array('RangeController')),
'FAN' => array('name' => __('Ventilateur', __FILE__), 'skills' => array('PowerController', 'RangeController')),
'GARAGE_DOOR' => array('name' => __('Porte de garage', __FILE__), 'skills' => array('ContactSensor')),
'GARAGE_DOOR' => array('name' => __('Porte de garage', __FILE__), 'skills' => array('ContactSensor', 'GarageDoorController')),
'MICROWAVE' => array('name' => __('Micro-onde', __FILE__), 'skills' => array('PowerController')),
'NETWORK_HARDWARE' => array('name' => __('Equipement réseaux', __FILE__), 'skills' => array('PowerController')),
'PRINTER' => array('name' => __('Imprimante', __FILE__), 'skills' => array('PowerController')),
Expand Down Expand Up @@ -204,6 +205,7 @@ public static function exec($_data) {
if (isset($return['event']['endpoint']['cookie'])) {
unset($return['event']['endpoint']['cookie']);
}
$return['event']['header']['messageId'] = vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex(random_bytes(16)), 4));
return $return;
}

Expand Down
129 changes: 129 additions & 0 deletions core/class/ash_GarageDoorController.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
<?php
require_once dirname(__FILE__) . '/../../../../core/php/core.inc.php';

class ash_GarageDoorController {

private static $_OPEN = array('GB_OPEN', 'GARAGE_OPEN');
private static $_CLOSE = array('GB_CLOSE', 'GARAGE_CLOSE');
private static $_STATE = array('GARAGE_STATE', 'BARRIER_STATE');

public static function discover($_device, $_eqLogic) {
$return = array();
$return['capabilities'] = array();

$return['capabilities']['Alexa.GarageDoorController'] = array (
'type' => 'AlexaInterface',
'interface' => 'Alexa.ModeController',
'instance' => 'GarageDoor.Position',
'version' => '3',
'properties' => array (
'supported' => array(array('name' => 'mode')),
'proactivelyReported' => false,
'retrievable' => false,
),
'capabilityResources' => array (
'friendlyNames' => array(
array('@type' => 'asset', 'value' => array ('assetId' => 'Alexa.Setting.Opening'))
),
),
'configuration' => array (
'ordered' => false,
'supportedModes' => array (
array(
'value' => 'Position.Up',
'modeResources' => array('friendlyNames' => array(array('@type' => 'asset', 'value' => array('assetId' => 'Alexa.Value.Open'))))
),
array(
'value' => 'Position.Down',
'modeResources' => array('friendlyNames' => array(array('@type' => 'asset', 'value' => array('assetId' => 'Alexa.Value.Close'))))
)
)
),
'semantics' => array (
'actionMappings' => array (
array (
'@type' => 'ActionsToDirective',
'actions' => array ('Alexa.Actions.Open', 'Alexa.Actions.Raise'),
'directive' => array ('name' => 'SetMode', 'payload' => array ('mode' => 'Position.Up'))
),
array (
'@type' => 'ActionsToDirective',
'actions' => array ('Alexa.Actions.Close', 'Alexa.Actions.Lower'),
'directive' => array ('name' => 'SetMode', 'payload' => array ('mode' => 'Position.Down'))
),
),
'stateMappings' => array (
array ('@type' => 'StatesToValue', 'states' => array ('Alexa.States.Open'), 'value' => 'Position.Up'),
array ('@type' => 'StatesToValue', 'states' => array ('Alexa.States.Closed'), 'value' => 'Position.Down'),
),
),
);

foreach ($_eqLogic->getCmd() as $cmd) {
if (in_array($cmd->getGeneric_type(), self::$_OPEN)) {
$return['cookie']['GarageDoorController_setOpen'] = $cmd->getId();
}
if (in_array($cmd->getGeneric_type(), self::$_CLOSE)) {
$return['cookie']['GarageDoorController_setClose'] = $cmd->getId();
}
if (in_array($cmd->getGeneric_type(), self::$_STATE)) {
$return['capabilities']['Alexa.GarageDoorController']['properties']['retrievable'] = true;
$return['cookie']['GarageDoorController_getState'] = $cmd->getId();
}
}

if (!isset($return['cookie']['GarageDoorController_setOpen']) || !isset($return['cookie']['GarageDoorController_setClose'])) {
return array();
}

return $return;
}

public static function needGenericType(){
return array(
__('Ouvrir',__FILE__) => self::$_OPEN,
__('Fermer',__FILE__) => self::$_CLOSE,
__('Etat',__FILE__) => self::$_STATE
);
}

public static function exec($_device, $_directive) {
if ($_directive['header']['name'] == 'SetMode') {
$mode = $_directive['payload']['mode'];
if ($mode == 'Position.Up' && isset($_directive['endpoint']['cookie']['GarageDoorController_setOpen'])) {
$cmd = cmd::byId($_directive['endpoint']['cookie']['GarageDoorController_setOpen']);
if (is_object($cmd)) $cmd->execCmd();
} else if ($mode == 'Position.Down' && isset($_directive['endpoint']['cookie']['GarageDoorController_setClose'])) {
$cmd = cmd::byId($_directive['endpoint']['cookie']['GarageDoorController_setClose']);
if (is_object($cmd)) $cmd->execCmd();
}
}
return self::getState($_device, $_directive);
}

public static function getState($_device, $_directive) {
$return = array();
$cmd = null;
if (isset($_directive['endpoint']['cookie']['GarageDoorController_getState'])) {
$cmd = cmd::byId($_directive['endpoint']['cookie']['GarageDoorController_getState']);
}
if (!is_object($cmd)) return $return;

$value = $cmd->execCmd();
if ($cmd->getSubtype() == 'binary' && $cmd->getDisplay('invertBinary') == 1) {
$value = ($value) ? 0 : 1;
}

$modeValue = ($value) ? 'Position.Up' : 'Position.Down';

$return[] = array(
'namespace' => 'Alexa.ModeController',
'instance' => 'GarageDoor.Position',
'name' => 'mode',
'value' => $modeValue,
'timeOfSample' => date('Y-m-d\TH:i:s\Z', strtotime($cmd->getValueDate())),
'uncertaintyInMilliseconds' => 0,
);
return array('properties' => $return);
}
}
1 change: 1 addition & 0 deletions core/class/ash_PowerController.class.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public static function exec($_device, $_directive) {
}
break;
}
usleep(500000);
return self::getState($_device, $_directive);
}

Expand Down
4 changes: 2 additions & 2 deletions core/class/ash_RangeController.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ public static function exec($_device, $_directive) {
$cmd->execCmd(array('slider' => $cmdState->execCmd() + $value));
}
case 'SetRangeValue':
if($_device->getOptions('OpenClose::invertSet',0) == 1){
$execution['payload']['rangeValue'] = 100 - $execution['payload']['rangeValue'];
if($_device->getOptions('RangeController::invertSet',0) == 1){
$_directive['payload']['rangeValue'] = 100 - $_directive['payload']['rangeValue'];
}
if (isset($_directive['endpoint']['cookie']['RangeController_setSlider'])) {
$cmd = cmd::byId($_directive['endpoint']['cookie']['RangeController_setSlider']);
Expand Down
Loading