Ejemplo n.º 1
0
 public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
 {
     if (value is string)
     {
         return(LoxoneUuid.Parse(value as string));
     }
     return(base.ConvertFrom(context, culture, value));
 }
Ejemplo n.º 2
0
 private string GetRoomName(LoxoneUuid room, Dictionary <LoxoneUuid, LoxAppModel.RoomModel> rooms)
 {
     if (rooms.ContainsKey(room))
     {
         return(rooms[room].Name);
     }
     return("unbekannt");
 }
Ejemplo n.º 3
0
 private bool IsIgnored(LoxoneUuid uuid, LoxAppModel.ControlModel controlModel)
 {
     if (this.loxoneConfig.IgnoreControls.Contains(uuid.ToString()))
     {
         return(true);
     }
     if (this.loxoneConfig.IgnoreCategories.Contains(controlModel.Cat.ToString()))
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 4
0
 private IEnumerable <Control> ParseControl(LoxoneUuid key, LoxAppModel.ControlModel loxControl, string roomName)
 {
     if (loxControl.Type == LoxAppModel.ControlTypeModel.Switch)
     {
         // is normal light switch?
         Control newControl = new Control(ControlType.LightControl,
                                          loxControl.Name,
                                          key,
                                          loxControl.Name,
                                          loxControl.States.ToImmutableDictionary <string, LoxoneUuid>(),
                                          roomName
                                          );
         return(new[] { newControl });
     }
     else if (loxControl.Type == LoxAppModel.ControlTypeModel.Dimmer)
     {
         // is dimmer?
         Control newControl = new Control(ControlType.LightDimmableControl,
                                          loxControl.Name,
                                          key,
                                          loxControl.Name,
                                          loxControl.States.ToImmutableDictionary <string, LoxoneUuid>(),
                                          roomName
                                          );
         return(new[] { newControl });
     }
     else if (loxControl.Type == LoxAppModel.ControlTypeModel.Jalousie)
     {
         // is blinds?
         Control newControl = new Control(ControlType.BlindControl,
                                          loxControl.Name,
                                          key,
                                          loxControl.Name,
                                          loxControl.States.ToImmutableDictionary <string, LoxoneUuid>(),
                                          roomName
                                          );
         return(new[] { newControl });
     }
     else if (loxControl.Type == LoxAppModel.ControlTypeModel.LightController)
     {
         // defer to subcontrols which should be switches and dimmers
         List <Control> controls = new List <Control>();
         foreach (var sc in loxControl.SubControls)
         {
             controls.AddRange(ParseControl(sc.Key, sc.Value, roomName));
         }
         return(controls);
     }
     log.Debug("Ignoring model control {0}: {1}, not supported type '{2}'", key, loxControl.Name, loxControl.Type);
     return(Enumerable.Empty <Control>());
 }
Ejemplo n.º 5
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            if (Object.ReferenceEquals(obj, this))
            {
                return(true);
            }
            if (!(obj is LoxoneUuid))
            {
                return(false);
            }

            LoxoneUuid other = obj as LoxoneUuid;

            return(this.Guid.Equals(other.Guid) && String.Equals(this.SubPath, other.SubPath));
        }
Ejemplo n.º 6
0
 public ControlBlinds(LoxoneUuid loxoneUuid, BlindCmd command)
 {
     this.LoxoneUuid = loxoneUuid;
     this.Command    = command;
 }
Ejemplo n.º 7
0
 public ControlDimmer(LoxoneUuid loxoneUuid, DimType dimType, int value)
 {
     this.LoxoneUuid = loxoneUuid;
     this.Type       = dimType;
     this.Value      = value;
 }
Ejemplo n.º 8
0
 public ControlSwitch(LoxoneUuid loxoneUuid, DesiredStateType desiredState)
 {
     this.LoxoneUuid   = loxoneUuid;
     this.DesiredState = desiredState;
 }
Ejemplo n.º 9
0
        private string TranslateToLoxoneOperation(LoxoneMessage.ControlSwitch.DesiredStateType desiredState, LoxoneUuid uuid)
        {
            switch (desiredState)
            {
            case LoxoneMessage.ControlSwitch.DesiredStateType.On:
                return("On");

            case LoxoneMessage.ControlSwitch.DesiredStateType.Off:
                return("Off");

            case LoxoneMessage.ControlSwitch.DesiredStateType.ByUuid:
                return(uuid.ToString());
            }
            string errMsg = $"DesiredStatte '{desiredState}' could not be translated";

            throw new Exception(errMsg);
        }