Hallo liebe Leute
Vielleicht kann mir einer ja bei meinem Problem helfen:
Ich habe von hier:
http://ipsview.brownson.at/?p=494http://
folgendes Skript zum dimmen meiner Homematic genutzt:
<?
/**
* @file IPSView_DimmerSynced.ips.php
* @author brownson
* @version
* Version 1.0, 2015-04-12 brownson: Initiale Version<br/>
*
* Skript um eine Switch Variable für einen Dimmer zu realisieren
*
* Konfiguration Einstellungen:
* DEVICE_DIMMER_ID ... ID der LEVEL Variable zum Setzen des Dimmer
* Wertes
* DEVICE_WORKING_ID ... ID der WORKING Variable, diese steuert die
* Synchronisierung des Wertes
*
*/
/*
* Konfiguration:
* -------------------------------------------------------------------------
*/
define ('DEVICE_DIMMER_ID', 41674 /*[Räume\Schlafzimmer\Dimmer\LEVEL]*/);
define ('DEVICE_WORKING_ID',56659 /*[Räume\Schlafzimmer\Dimmer\WORKING]*/);
/*
* Programmlogik:
* -------------------------------------------------------------------------
*/
$scriptID = $_IPS['SELF'];
$sender = $_IPS['SENDER'];
$parentID = IPS_GetParent($scriptID);
$variableIDSwitch = CreateVariable('IPSView_Switch', 0, $parentID, 10,
'~Switch', $scriptID);
$variableIDDimmer = CreateVariable('IPSView_Dimmer', 2, $parentID, 20, '',
$scriptID, DEVICE_DIMMER_ID);
if ($sender=='Execute') {
CreateEvent ('IPSView_DimmerSync', DEVICE_DIMMER_ID, $scriptID);
CreateEvent ('IPSView_WorkingSync', DEVICE_WORKING_ID, $scriptID);
} else if ($sender=='Variable') {
$value = GetValue(DEVICE_DIMMER_ID);
if (DEVICE_WORKING_ID==0 or !GetValue(DEVICE_WORKING_ID)) {
SetValue($variableIDSwitch, ($value > 0));
SetValue($variableIDDimmer, $value);
}
} else {
$variableId = $_IPS['VARIABLE'];
$value = $_IPS['VALUE'];
switch ($variableId) {
case $variableIDDimmer:
Dimmer_SetDeviceValue($value);
SetValue($variableIDSwitch, ($value > 0));
SetValue($variableIDDimmer, $value);
break;
case $variableIDSwitch:
if ($value)
Dimmer_SetDeviceValue(GetValue($variableIDDimmer));
else
Dimmer_SetDeviceValue(0);
SetValue($variableId, $value);
break;
default:
break;
}
}
/*
* Funktionen:
* -------------------------------------------------------------------------
*/
function Dimmer_SetDeviceValue($value) {
$instanceID = IPS_GetParent(DEVICE_DIMMER_ID);
$ident = IPS_GetObject(DEVICE_DIMMER_ID)['ObjectIdent'];
IPS_RequestAction($instanceID, $ident, $value);
}
function CreateVariable ($name, $type, $parentId, $position=0, $profile="",
$action=null, $referenceID=null) {
$variableId = @IPS_GetObjectIDByIdent($name, $parentId);
if ($variableId === false) {
$variableId = IPS_CreateVariable($type);
IPS_SetParent($variableId, $parentId);
IPS_SetName($variableId, $name);
IPS_SetIdent($variableId, $name);
IPS_SetPosition($variableId, $position);
if ($referenceID != null) {
$variable = IPS_GetVariable($referenceID);
$profile = $variable['VariableProfile'];
}
IPS_SetVariableCustomProfile($variableId, $profile);
IPS_SetVariableCustomAction($variableId, $action);
}
return $variableId;
}
function CreateEvent ($name, $variableId, $scriptId) {
$eventId = @IPS_GetObjectIDByIdent($name, $scriptId);
if ($eventId === false) {
$eventId = IPS_CreateEvent(0);
IPS_SetParent($eventId, $scriptId);
IPS_SetName($eventId, $name);
IPS_SetIdent($eventId, $name);
IPS_SetEventTrigger($eventId, 1/*ByChange*/, $variableId);
IPS_SetEventActive($eventId, true);
}
return $eventId;
}
?>
Es klappt auch alles Super. Nur wenn der Level auf 0% steht und ich den Switch betätige zum einschalten, passiert nichts. Schön wäre wenn dann das licht auf 100% angeht oder auf den letzten Wert, der aber nicht 0 ist. Einen Schalter zu betätigen, und nichts passiert, ist nicht so schön.
Vielen Dank.
P.S. Kleine Frage noch nebendran. Wie kann ich in IPS View ein Feld erzeugen, um z.B. den Sollwert mittels Texteingabe einzustellen. (Keine Slider)