Gå til innhold
  • Bli medlem
Støtt hjemmeautomasjon.no!
  • 0

Homeseer med homebridge på Pi


gullfrode

Spørsmål

Noen som har satt opp homebridge på feks en pi og har config-fil og dele?

Litt merjobb enn på HC2 virker det som, der hadde en lagd pluginen slik at den hentet alle devicer gruppert etter rom, dvs. lett å legge til i Homekit. 

Brukte mye til feks. å åpne garasjeporten med Siri, da ikke akkurat Fibaro-appen er kjapp på iOS. Homebridge var relativt kjapp. 

HS3Touch velger jeg å ikke kommentere:o)

Lenke til kommentar
Del på andre sider

15 svar til spørsmålet

Anbefalte innlegg

  • 0

Det er en del sensorer osv som ikke automatisk kommer med her, så da kan man legge til enheter ved å redigere Config.json filen.

 

Jeg buker FileZilla på Mac for å redigere den, koble til med SSH på Raspeberry ip adresse. Brukernavn: pi Pass: raspberry

 

Sti: /var/lib/homebridge velg config.json høyreklikk og velg vis/rediger

 

Bevegelse Sensor:

        {
          "ref": 728,
          "type": "MotionSensor",
          "name": "Garasje Bevegelsesensor"
        },

 

Wall plug:

        {
          "ref": 737,
          "type": "Outlet",
          "name": "Varmtvannstank",
          "offValue": "0",
          "onValue": "255",
          "can_dim": false,

          "uuid_base": "NonDimmable737"

         },

 

Bryter:

        {
          "ref": 778,
          "type": "Switch",
          "name": "Sirene Gang",
          "offValue": "0",
          "onValue": "255",
          "can_dim": false,
          "uuid_base": "NonDimmable778"
        },
 

Temperatursensor:

        {       
          "ref":304,
          "type":"TemperatureSensor",
          "temperatureUnit":"C",
          "name":"Utetemperatur"
        },
 

Lys Sensor:

        {       
          "ref":731,
          "type":"LightSensor",
          "name":"Garasje Lyssensor"
        },
 

Fuktighet Sensor:

        {       
          "ref":318,
          "type":"HumiditySensor",
          "name":"Gjesterom Fuktighet"
        },
 

Dør Sensor:

        {       
          "ref":358,
          "type":"Door",
          "name":"Postkasse"
        },
 

Vindu Sensor:

        {       
          "ref":507,
          "type":"Window",
          "name":"Sophia Vindu"
        },
 

CO2 Sensor (Denne skal jeg forske litt mer på) 

 

        {       
          "ref":317,
          "type":"CarbonMonoxideSensor",
          "name":"Gjesterom Co2"
        },
 

Garasjeport (basert på 2 enheter der man har egen magnetkontakt og rele for åpning)

{
          "ref": 718,
          "type": "GarageDoorOpener",
          "name": "Garasjeport Høyre",
          "stateRef": 713,
          "statusUpdateCount": 5,
          "stateOpenValues": [
            255
          ],
          "stateClosedValues": [
            0
          ],
          "controlRef": 718,
          "controlOpenValue": 255,
          "controlCloseValue": 255,
          "uuid_base": "GarageDoor718"
        },
 

 

Endret av kimstoroy
  • Like 1
Lenke til kommentar
Del på andre sider

  • 0

https://www.npmjs.com/package/homebridge-homeseer

 

// SUPORTED TYPES:
// - Lightbulb              (can_dim, onValue, offValue options)
// - Fan                    (onValue, offValue options)
// - Switch                 (onValue, offValue options)
// - Outlet                 (onValue, offValue options)
// - Thermostat             (temperatureUnit, setPoint, state, control options)
// - TemperatureSensor      (temperatureUnit=C|F)
// - HumiditySensor         (HomeSeer device value in %  - batteryRef, batteryThreshold options)
// - LightSensor            (HomeSeer device value in Lux  - batteryRef, batteryThreshold options)
// - ContactSensor          (onValues, batteryRef, batteryThreshold options)
// - MotionSensor           (onValues, batteryRef, batteryThreshold options)
// - LeakSensor             (onValues, batteryRef, batteryThreshold options)
// - OccupancySensor        (onValues, batteryRef, batteryThreshold options)
// - SmokeSensor            (onValues, batteryRef, batteryThreshold options)
// - CarbonMonoxideSensor   (onValues, batteryRef, batteryThreshold options)
// - CarbonDioxideSensor    (onValues, batteryRef, batteryThreshold options)
// - Battery                (batteryThreshold option)
// - GarageDoorOpener       (state, control, obstruction, lock options)
// - Lock                   (unsecured, secured, jammed options)
// - SecuritySystem         (arm, disarm options)
// - Door                   (obstruction option)
// - Window                 (obstruction option)
// - WindowCovering         (obstruction option)
 
Kom på det var kjekt å bytte til Switch på enkelte, feks Greenwavegrenkontaktene jeg har. Dumt at jeg sier «Skru av lys på stua», så skrus spenning av til Tv og andre mediating. 
Lenke til kommentar
Del på andre sider

  • 0

Kona maste om å styre markisen fra tlf. Slet litt med å legge til med den gamle plugin på pi, så la inn 2018-versjonen på windowsmaskinen med HS3 i stedet. 

Der hadde Valve kommet og, ser litt tøffere ut en brytere(type 2, som er Irregation, har lagt til timer, derfor det står inaktiv).

var gjort om en del på parameterne på lås og port, så måtte endre litt på configfila. 

 

816515F9-B6A2-49A2-A57E-893FB9A39D77.png

Lenke til kommentar
Del på andre sider

  • 0
{
	"bridge": {
		"name": "Homebridge",
		"username": "CC:22:3D:E3:CE:30",
		"port": 51826,
		"pin": "xxx-xx-xxx"
	},
	"platforms": [{
		"platform": "HomeSeer",
		"name": "HomeSeer",
		"host": "Hiphs3",
		"accessories": [{
				"ref": 431,
				"type": "Lightbulb",
				"name": "Vindu Høyre",
				"offValue": "0",
				"onValue": "99",
				"can_dim": true,
				"uuid_base": "DimmableLight431"
			},
			{
				"ref": 401,
				"type": "Lightbulb",
				"name": "Vitrineskapet",
				"offValue": "0",
				"onValue": "99",
				"can_dim": true,
				"uuid_base": "DimmableLight401"
			},
			{
				"ref": 440,
				"type": "Lightbulb",
				"name": "Vindu Venstre",
				"offValue": "0",
				"onValue": "99",
				"can_dim": true,
				"uuid_base": "DimmableLight440"
			},
			{
				"ref": 728,
				"type": "Lightbulb",
				"name": "Snekkerbua Lys",
				"offValue": "0",
				"onValue": "255",
				"can_dim": false,
				"uuid_base": "NonDimmable728"
			},
			{
				"ref":604,
				"type":"TemperatureSensor",
				"temperatureUnit":"C",
				"name":"Bak garasjen",
				"uuid_base": "Temp604"
            },{
				"ref":1026,
				"type":"TemperatureSensor",
				"temperatureUnit":"C",
				"name":"Garasje",
				"uuid_base": "Temp1026"
            },
            {
				"ref":6968,
				"type":"TemperatureSensor",
				"temperatureUnit":"C",
				"name":"Terassen",
				"uuid_base": "Temp6968"
            },
            {
				"ref":846,
				"type":"TemperatureSensor",
				"temperatureUnit":"C",
				"name":"Stua",
				"uuid_base": "Temp846"
            },
            {
	            "ref":893,
	            "type":"ContactSensor",
	            "name":"Balkongdør status",
	            "offValues":[23],
				"uuid_base": "Motion893"
	        },
	        {
	            "ref":903,
	            "type":"ContactSensor",
	            "name":"Ytterdør status",
				"uuid_base": "Motion903"
	        },
			{
				"ref": 1009,
				"type": "WindowCovering",
				"name": "Markise terassen",
				"closedValue": 0,
				"openValue": 255,
				"uuid_base": "NonDimmable1009"
			},
			{
				"ref": 294,
				"type": "WindowCovering",
				"name": "Markise Sør",
				"closedValue": 0,
				"openValue": 255,
				"uuid_base": "NonDimmable294"
			},
			{
				"ref": 511,
				"type": "Valve",
				"name": "Vann Barnekjøkken",
				"closeValve": "0",
				"openValve": "255",
				"valveType": 1,
				"useTimer": true,
				"minTime": 60,
				"uuid_base": "NonDimmable511"
			},
			{
				"ref": 508,
				"type": "Valve",
				"name": "Vann Vest",
				"closeValve": "0",
				"openValve": "255",
				"valveType": 1,
				"useTimer": true,
				"minTime": 30,
				"uuid_base": "NonDimmable508"
			},
			{
				"ref": 507,
				"type": "Valve",
				"name": "Vann Sør",
				"closeValve": "0",
				"openValve": "255",
				"valveType": 1,
				"useTimer": true,
				"minTime": 30,
				"uuid_base": "NonDimmable507"
			},
			{
				"ref": 510,
				"type": "Valve",
				"name": "Vann Nordøst",
				"closeValve": "0",
				"openValve": "255",
				"valveType": 1,
				"useTimer": true,
				"minTime": 30,
				"uuid_base": "NonDimmable510"
			},
			{
				"ref": "6899",
				"type": "Lock",
				"name": "Ytterdøra",
				"unlockValue": 0,
				"lockValue": 255,
				"uuid_base": "DoorLock6899"
			},
			{
				"ref": 5763,
				"type": "GarageDoorOpener",
				"name": "Garasjeport","openValue": 1,
				"closedValue": 2,
				"openingValue": 254,
	"closingValue": 252,
	"stoppedValue": 253,
				"uuid_base": "GarageDoor5763"
			}
		]
	}]
}

 

  • Like 1
Lenke til kommentar
Del på andre sider

  • 0

Tenkte å prøve å få Moskus sitt Termostatscript inn i Homebridge.

Noen som vet om det er bare å endre i .ini-fila samt Values i Heating-device for å endre verdiene?

Ikke noen mulighet for å definere i config-fila i homebridge ennå.

{
	"type": "Thermostat",
	"name":null,
	"ref": 0,					// Set to HomeSeer device reporting the current temperature.
	"uuid_base": 0,
	"batteryRef": 0,
	"batteryThreshold": 25,
	"temperatureUnit":"F",	
	"controlRef": 0,			// Set to HomeSeer device by which you select the Off / Heat / Cool / Auto state.
	"stateRef": 0,				// Set to HomeSeer device reporting the actually running state (Off / Heat / Cool). Sometimes this is the same as controlRef!
	"heatingSetpointRef": 0,	// Either "heatingSetpointRef" or "coolingSetpointRef" must be set (usually both are!)
	"coolingSetpointRef": 0,	// Either "heatingSetpointRef" or "coolingSetpointRef" must be set (usually both are!)
	"humidityRef": 0,			// optional. Set to HomeSeer device that provides a humidity report.
	"humidityTargetRef": 0		// optional. Set to HomeSeer device that allows you to set humidity setpoint.
},

I en standard termostat så er vel 

0=Off

1=Heat

2=Cool

og 11=Energy Save Heat

 

I Moskus sitt script så er 

0=Off

1=Manual

2=Low

3=High

4=Auto

Lenke til kommentar
Del på andre sider

  • 0
1 time siden, gullfrode skrev:

Spørsmålet var egentlig at om jeg kan endre Value 4 Auto til Value 1 på noen måte, i termostaten fra deg. 

Det er foreløpig ikke noen routingmuligheter i homebridge

Jo, selvfølgelig, men du må programmere om litt. Ikke at det er vanskelig, men det må gjøres. 

 

Det beste er å slette de eksisterende termostatene du har satt opp (eller endre på GraphicValues selv), og så endre dette:

Private Enum Modes
    Off = 0
    Manual = 1
    Low = 2
    High = 3
    Auto = 4
End Enum

til dette:

Private Enum Modes
    Off = 0
    Auto = 1
    Low = 2
    High = 3
    Manual = 4
End Enum

Og så er det bare å sette opp nye termostater. :) 

Lenke til kommentar
Del på andre sider

  • 0

Takker og bukker!

High og Auto ble motsatt, så da blir scriptet slik(starter dagen litt tidligere enn dere)

' Moskus 2017'Version 0.0.1Private scriptName As String = "VirtualThermostat"Private scriptFile As String = scriptName & ".vb"Public Sub Main(ByVal rootDeviceRef As Object)   'Devices:   'Root: Heating, Cooling   'Mode: Manual, High, Low, Off   'Thermostat: Range 5 - 40, step 0.5   'Temperature: Adjusted for locationEnd SubPrivate Enum Modes   Off = 0   High = 1   Low = 2   Auto = 3   Manual = 4End EnumPrivate Enum ThermostatDeviceType   Thermostat_Root = 0   Thermostat_Mode = 1   Thermostat_Setpoint = 2   Thermostat_Temperature = 3End EnumPublic Sub UpdateConfig(ByVal input As Object)   Dim rootDeviceRef As Integer = CInt(input.ToString.Split("|")(0))   Dim s As New ThermostatSettings(hs, rootDeviceRef)   s.Load(input.ToString.Split("|")(1))   s.Save(hs, rootDeviceRef)End SubPublic Sub Setup(ByVal inputString As Object)   'HeaterDeviceReference=860,ExternalTemperatureSensorRef=521   Dim useFahrenheit As Boolean = hs.GetINISetting("Settings", "gGlobalTempScaleF", "False", "settings.ini")   Try       Dim SVpair As HomeSeerAPI.VSPair       Dim VGpair As HomeSeerAPI.VGPair       '=============       'Root device       'Mode device       '=============       Dim rootRef As Integer = hs.NewDeviceRef("Thermostat mode")       Dim rootDevice As Scheduler.Classes.DeviceClass = hs.GetDeviceByRef(rootRef)       rootDevice.Location(hs) = scriptName       rootDevice.Location2(hs) = scriptName       rootDevice.Device_Type_String(hs) = ThermostatDeviceType.Thermostat_Mode.ToString       rootDevice.DeviceType_Set(hs) = New HomeSeerAPI.DeviceTypeInfo       rootDevice.Status_Support(hs) = True       rootDevice.Can_Dim(hs) = False       hs.SaveEventsDevices()       rootDevice.MISC_Set(hs, HomeSeerAPI.Enums.dvMISC.SHOW_VALUES)       rootDevice.MISC_Clear(hs, HomeSeerAPI.Enums.dvMISC.STATUS_ONLY)       rootDevice.MISC_Set(hs, HomeSeerAPI.Enums.dvMISC.NO_LOG)       For i As Integer = 0 To 4           Dim value As Modes = i           SVpair = New HomeSeerAPI.VSPair(HomeSeerAPI.ePairStatusControl.Status)           SVpair.PairType = HomeSeerAPI.VSVGPairType.SingleValue           SVpair.Value = CInt(value)           SVpair.Status = value.ToString           hs.DeviceVSP_AddPair(rootRef, SVpair)           VGpair = New HomeSeerAPI.VGPair           VGpair.PairType = HomeSeerAPI.VSVGPairType.SingleValue           VGpair.Set_Value = CInt(value)           Select Case CInt(value)               Case Is = Modes.Off                   VGpair.Graphic = "images/HomeSeer/contemporary/off.gif"               Case Is = Modes.Manual                   VGpair.Graphic = "images/HomeSeer/contemporary/yellow.png"               Case Is = Modes.Low                   VGpair.Graphic = "images/HomeSeer/contemporary/blue.png"               Case Is = Modes.High                   VGpair.Graphic = "images/HomeSeer/contemporary/red.png"               Case Is = Modes.Auto                   VGpair.Graphic = "images/HomeSeer/contemporary/green.png"           End Select           hs.DeviceVGP_AddPair(rootRef, VGpair)           hs.DeviceScriptButton_AddButton(rootRef, value.ToString, CInt(value), scriptFile, "ModeButtonPress", CInt(value), 1, CInt(value) + 1, 1)       Next       'Storing settings in ini file       Dim s As New ThermostatSettings(inputString.ToString)       s.Save(hs, rootRef)       'Setting up initial schedule       hs.SaveINISetting("Schedule", "5:00", "High", scriptName & "_" & rootRef & ".ini")       hs.SaveINISetting("Schedule", "8:00", "Low", scriptName & "_" & rootRef & ".ini")       hs.SaveINISetting("Schedule", "13:00", "High", scriptName & "_" & rootRef & ".ini")       hs.SaveINISetting("Schedule", "23:00", "Low", scriptName & "_" & rootRef & ".ini")       'Setting up initial alternative schedule       hs.SaveINISetting("AlternativeSchedule", "6:00", "High", scriptName & "_" & rootRef & ".ini")       hs.SaveINISetting("AlternativeSchedule", "23:00", "Low", scriptName & "_" & rootRef & ".ini")       '=============       'Setpoint device       '=============       Dim setpointRef As Integer = hs.NewDeviceRef("Thermostat setpoint")       Dim setpointDevice As Scheduler.Classes.DeviceClass = hs.GetDeviceByRef(setpointRef)       setpointDevice.Location(hs) = scriptName       setpointDevice.Location2(hs) = scriptName       setpointDevice.Device_Type_String(hs) = ThermostatDeviceType.Thermostat_Setpoint.ToString       setpointDevice.DeviceType_Set(hs) = New HomeSeerAPI.DeviceTypeInfo       setpointDevice.Status_Support(hs) = True       setpointDevice.Can_Dim(hs) = False       hs.SaveEventsDevices()       setpointDevice.MISC_Set(hs, HomeSeerAPI.Enums.dvMISC.SHOW_VALUES)       setpointDevice.MISC_Clear(hs, HomeSeerAPI.Enums.dvMISC.STATUS_ONLY)       setpointDevice.MISC_Set(hs, HomeSeerAPI.Enums.dvMISC.NO_LOG)       Dim tempStart As Double = 5       Dim tempEnd As Double = 35       Dim forStep As Double = 0.5       Dim scale As String = "C"       If useFahrenheit Then           tempStart = 41           tempEnd = 95           forStep = 1           scale = "F"       End If       For i As Double = tempStart To tempEnd Step forStep           SVpair = New HomeSeerAPI.VSPair(HomeSeerAPI.ePairStatusControl.Both)           SVpair.PairType = HomeSeerAPI.VSVGPairType.SingleValue           SVpair.Value = i           SVpair.Status = i & " °" & scale           SVpair.Render = HomeSeerAPI.Enums.CAPIControlType.Values           SVpair.Render_Location.Row = 1           SVpair.Render_Location.Column = 1           SVpair.Render_Location.ColumnSpan = 1           hs.DeviceVSP_AddPair(setpointRef, SVpair)       Next       If useFahrenheit Then           hs.SetDeviceValueByRef(setpointRef, 64, False)       Else           hs.SetDeviceValueByRef(setpointRef, 17.5, False)       End If       hs.DeviceScriptButton_AddButton(setpointRef, "-", 200, scriptFile, "SetpointButtonPress", ScriptParm:=200, Row:=1, Column:=2, ColumnSpan:=1)       hs.DeviceScriptButton_AddButton(setpointRef, "+", 201, scriptFile, "SetpointButtonPress", ScriptParm:=201, Row:=1, Column:=3, ColumnSpan:=1)       VGpair = New HomeSeerAPI.VGPair       VGpair.PairType = HomeSeerAPI.VSVGPairType.Range       VGpair.RangeStart = 0       VGpair.RangeEnd = 1000       VGpair.Graphic = "images/HomeSeer/contemporary/Thermometer-50.png"       hs.DeviceVGP_AddPair(setpointRef, VGpair)       '=============       'Temperature device       '=============       Dim roomTempRef As Integer = hs.NewDeviceRef("Thermostat room temp")       Dim roomTempDevice As Scheduler.Classes.DeviceClass = hs.GetDeviceByRef(roomTempRef)       roomTempDevice.Location(hs) = scriptName       roomTempDevice.Location2(hs) = scriptName       roomTempDevice.Device_Type_String(hs) = ThermostatDeviceType.Thermostat_Temperature.ToString       roomTempDevice.DeviceType_Set(hs) = New HomeSeerAPI.DeviceTypeInfo       roomTempDevice.Status_Support(hs) = True       roomTempDevice.Can_Dim(hs) = False       hs.SaveEventsDevices()       roomTempDevice.MISC_Set(hs, HomeSeerAPI.Enums.dvMISC.SHOW_VALUES)       roomTempDevice.MISC_Set(hs, HomeSeerAPI.Enums.dvMISC.STATUS_ONLY)       roomTempDevice.MISC_Set(hs, HomeSeerAPI.Enums.dvMISC.NO_LOG)       SVpair = New HomeSeerAPI.VSPair(HomeSeerAPI.ePairStatusControl.Status)       SVpair.PairType = HomeSeerAPI.VSVGPairType.Range       SVpair.RangeStart = -1000       SVpair.RangeEnd = 1000       SVpair.RangeStatusSuffix = " °" & scale       SVpair.RangeStatusDecimals = 1       hs.DeviceVSP_AddPair(roomTempRef, SVpair)       VGpair = New HomeSeerAPI.VGPair       VGpair.PairType = HomeSeerAPI.VSVGPairType.Range       VGpair.RangeStart = -1000       VGpair.RangeEnd = 1000       VGpair.Graphic = "images/HomeSeer/contemporary/Thermometer-90.png"       hs.DeviceVGP_AddPair(roomTempRef, VGpair)       'Save devices       hs.SaveEventsDevices()       'Associating devices       rootDevice.Relationship(hs) = HomeSeerAPI.Enums.eRelationship.Parent_Root       rootDevice.AssociatedDevice_Add(hs, setpointRef)       rootDevice.AssociatedDevice_Add(hs, roomTempRef)       setpointDevice.Relationship(hs) = HomeSeerAPI.Enums.eRelationship.Child       setpointDevice.AssociatedDevice_Add(hs, rootRef)       roomTempDevice.Relationship(hs) = HomeSeerAPI.Enums.eRelationship.Child       roomTempDevice.AssociatedDevice_Add(hs, rootRef)       'Setting up events       Dim eventRef As Integer = hs.NewEventGetRef("Thermostat " & rootRef, "Virtual Thermostat", "")       hs.EventSetRecurringTrigger(eventRef, New TimeSpan(0, 5, 0), False, True)       hs.AddActionRunScript(eventRef, "VirtualThermostat.vb", "CheckTemperature", rootRef)       hs.WriteLog("Virtual Thermostat", "New thermostat created successfully!")   Catch ex As Exception       hs.WriteLog("Virtual Thermostat", "Error creating root device: " & ex.Message)   End TryEnd SubPublic Sub ModeButtonPress(ByVal input As Object)   Dim rootDeviceRef As Integer = input(0)   Dim value As Modes = input(1)   Dim s As New ThermostatSettings(hs, rootDeviceRef)   'Updating the mode device   hs.SetDeviceValueByRef(rootDeviceRef, CInt(value), True)   'Updating the temperature device   Select Case value       Case = Modes.Off           TurnOff(rootDeviceRef)       Case Is = Modes.Low           hs.SetDeviceValueByRef(GetChildReference(rootDeviceRef, ThermostatDeviceType.Thermostat_Setpoint), s.TemperatureLow, True)       Case Is = Modes.High           hs.SetDeviceValueByRef(GetChildReference(rootDeviceRef, ThermostatDeviceType.Thermostat_Setpoint), s.TemperatureHigh, True)       Case Is = Modes.Auto           Dim temp As Double = GetSetpointFromSchedule(rootDeviceRef)           hs.SetDeviceValueByRef(GetChildReference(rootDeviceRef, ThermostatDeviceType.Thermostat_Setpoint), temp, True)   End Select   If value > Modes.Off Then CheckTemperature(rootDeviceRef)End SubPublic Sub SetpointButtonPress(ByVal input As Object)   Dim setpointDeviceRef As Integer = input(0)   Dim value As Integer = input(1)   'Get the current setpoint value   Dim devValue As Double = hs.DeviceValueEx(setpointDeviceRef)   'Set the new setpoint value   Select Case value       Case = 200 'Down           hs.SetDeviceValueByRef(setpointDeviceRef, devValue - 0.5, True)       Case 201 'Up           hs.SetDeviceValueByRef(setpointDeviceRef, devValue + 0.5, True)   End Select   'Find the root device (the setpoint device is only associated to the root device)   Dim setpointDevice As Scheduler.Classes.DeviceClass = hs.GetDeviceByRef(setpointDeviceRef)   Dim rootDeviceRef As Integer = 0   If setpointDevice.AssociatedDevices_Count(hs) = 1 Then       rootDeviceRef = setpointDevice.AssociatedDevices(hs)(0)   End If   If rootDeviceRef > 0 Then       'Set the mode to "manual"       If hs.DeviceValue(rootDeviceRef)  Modes.Manual Then hs.SetDeviceValueByRef(rootDeviceRef, Modes.Manual, True)       'Check the temperature and adjust the heater as needed       CheckTemperature(rootDeviceRef)   Else       hs.WriteLog(scriptName, "Could not find root device for setpoint device")   End IfEnd SubPrivate Function GetChildReference(ByVal rootDeviceRef As Integer, ByVal deviceType As ThermostatDeviceType) As Integer   Dim root As Scheduler.Classes.DeviceClass = hs.GetDeviceByRef(rootDeviceRef)   For Each i As Integer In root.AssociatedDevices(hs)       Dim child As Scheduler.Classes.DeviceClass = hs.GetDeviceByRef(i)       If child.Device_Type_String(hs).ToString = deviceType.ToString Then           Return i       End If   Next   Return 0End FunctionPrivate Sub UpdateTemperatureDevice(ByVal rootDeviceRef As Integer)   Dim s As New ThermostatSettings(hs, rootDeviceRef)   Dim roomTemperature As Double = Math.Round((hs.DeviceValueEx(s.ExternalTemperatureSensorRef) + s.TemperatureCorrectionAddition) * s.TemperatureCorrectionMultiplier, 1)   hs.SetDeviceValueByRef(GetChildReference(rootDeviceRef, ThermostatDeviceType.Thermostat_Temperature), roomTemperature, True)End SubPublic Sub CheckTemperature(ByVal rootDeviceRef As Object)   Dim s As New ThermostatSettings(hs, CInt(rootDeviceRef))   UpdateTemperatureDevice(rootDeviceRef)   Dim currentMode As Modes = hs.DeviceValue(rootDeviceRef)   'If the root is Off, then    If currentMode = Modes.Off Then Exit Sub   'Check mode for auto, and update the setpoint device   If currentMode = Modes.Auto Then       Dim scheduleTemp As Double = GetSetpointFromSchedule(rootDeviceRef)       hs.SetDeviceValueByRef(GetChildReference(rootDeviceRef, ThermostatDeviceType.Thermostat_Setpoint), scheduleTemp, True)   End If   'Get roomtemperature from device and setpoints   Dim roomTemperature As Double = hs.DeviceValueEx(GetChildReference(rootDeviceRef, ThermostatDeviceType.Thermostat_Temperature))   Dim setPoint As Double = hs.DeviceValueEx(GetChildReference(rootDeviceRef, ThermostatDeviceType.Thermostat_Setpoint))   Dim lowSetPoint As Double = setPoint - s.TemperatureOffset   'Set the mode button to manual if the temperature is not equal to TempHigh or TempLow and the mode is not Off or Auto   If currentMode  Modes.Auto AndAlso currentMode  Modes.Off Then       If setPoint  s.TemperatureHigh AndAlso setPoint  s.TemperatureLow Then           hs.SetDeviceValueByRef(rootDeviceRef, Modes.Manual, True)       End If   End If   If roomTemperature         TurnOn(rootDeviceRef)       If s.Log Then hs.WriteLog(scriptName, "Heating ON  - Temp: " & roomTemperature & "° - , Setpoint: " & setPoint & "°")   ElseIf roomTemperature > lowSetPoint AndAlso roomTemperature         Idle()       If s.Log Then hs.WriteLog(scriptName, "Heating IDLE - Temp: " & roomTemperature & "° - , Setpoint: " & setPoint & "°")   ElseIf roomTemperature > setPoint Then       TurnOff(rootDeviceRef)       If s.Log Then hs.WriteLog(scriptName, "Heating OFF - Temp: " & roomTemperature & "° - , Setpoint: " & setPoint & "°")   Else       If s.Log Then hs.WriteLog(scriptName, "Heating status unchanged - Temp: " & roomTemperature & "° - Setpoint: " & setPoint & "°")   End IfEnd SubPrivate Sub TurnOff(ByVal rootDeviceRef As Object)   Dim s As New ThermostatSettings(hs, rootDeviceRef)   Dim cc As HomeSeerAPI.CAPI.CAPIControl = hs.CAPIGetSingleControlByUse(s.HeaterDeviceReference, HomeSeerAPI.ePairControlUse._Off)   Dim ccResponse As HomeSeerAPI.CAPI.CAPIControlResponse = hs.CAPIControlHandler(cc)   If s.Log Then hs.WriteLog("Virtual Thermostat", "Turn Off: " & ccResponse.ToString & " for device " & s.HeaterDeviceReference)End SubPrivate Sub TurnOn(ByVal rootDeviceRef As Integer)   Dim s As New ThermostatSettings(hs, rootDeviceRef)   Dim cc As HomeSeerAPI.CAPI.CAPIControl = hs.CAPIGetSingleControlByUse(s.HeaterDeviceReference, HomeSeerAPI.ePairControlUse._On)   Dim ccResponse As HomeSeerAPI.CAPI.CAPIControlResponse = hs.CAPIControlHandler(cc)   If s.Log Then hs.WriteLog("Virtual Thermostat", "Turn On: " & ccResponse.ToString & " for device " & s.HeaterDeviceReference)End SubPrivate Sub Idle()   'Do nothingEnd SubPrivate Function GetSetpointFromSchedule(ByVal rootDeviceRef As Integer) As Double   Dim s As New ThermostatSettings(hs, rootDeviceRef)   Dim schedule As System.Collections.Generic.List(Of String)   Dim scheduleArray() As String   If s.AlternativeScheduleDeviceReference > 0 Then       If hs.IsOff(s.AlternativeScheduleDeviceReference) Then           scheduleArray = hs.GetINISectionEx("Schedule", scriptName & "_" & rootDeviceRef & ".ini")       Else           scheduleArray = hs.GetINISectionEx("AlternativeSchedule", scriptName & "_" & rootDeviceRef & ".ini")       End If   Else       scheduleArray = hs.GetINISectionEx("Schedule", scriptName & "_" & rootDeviceRef & ".ini")   End If   schedule = scheduleArray.ToList   'Failsafe if no schedule is found   If schedule.Count = 0 Then Return s.TemperatureLow   If Not schedule(0).StartsWith("0:00") Then       schedule.Insert(0, "0:00=Low")   End If   schedule.Add("24:00=Low")   Dim timeNow As Double = Now.Hour + Now.Minute / 60   For i As Integer = 0 To schedule.Count - 2       Dim line() As String = schedule(i).Split("=")       Dim nextLine() As String = schedule(i + 1).Split("=")       Dim time_this As Double = line(0).Split(":")(0) + line(0).Split(":")(1) / 60       Dim time_next As Double = nextLine(0).Split(":")(0) + nextLine(0).Split(":")(1) / 60       If timeNow >= time_this AndAlso timeNow             Select Case line(1)               Case = "High"                   Return s.TemperatureHigh               Case = "Low"                   Return s.TemperatureLow               Case Else                   Dim temp As Double = 0                   Dim success As Boolean = Double.TryParse(line(1), temp)                   If Not success Then hs.WriteLog(scriptName, "Error parsing value in schedule at time: " + line(i))                   Return temp           End Select       End If   Next   Return 0End FunctionClass ThermostatSettings   Public Property ExternalTemperatureSensorRef As Integer = 0   Public Property TemperatureCorrectionMultiplier As Integer = 1   Public Property TemperatureCorrectionAddition As Integer = 0   Public Property TemperatureOffset As Double = 0.3   Public Property HeaterDeviceReference As Integer = 0   Public Property TemperatureHigh As Double = 23   Public Property TemperatureLow As Double = 16   Public Property AlternativeScheduleDeviceReference = 0   Public Property Log As Boolean = False   Private scriptName As String = "VirtualThermostat"   Public Sub Save(ByRef hs As Object, ByVal rootDeviceRef As Integer)       Dim filename As String = scriptName & "_" & rootDeviceRef & ".ini"       hs.SaveINISetting("Settings", "ExternalTemperatureSensorRef", Me.ExternalTemperatureSensorRef, filename)       hs.SaveINISetting("Settings", "TemperatureCorrectionAddition", Me.TemperatureCorrectionAddition, filename)       hs.SaveINISetting("Settings", "TemperatureCorrectionMultiplier", Me.TemperatureCorrectionMultiplier, filename)       hs.SaveINISetting("Settings", "TemperatureOffset", Me.TemperatureOffset, filename)       hs.SaveINISetting("Settings", "Log", Me.Log, filename)       hs.SaveINISetting("Settings", "HeaterDeviceReference", Me.HeaterDeviceReference, filename)       hs.SaveINISetting("Settings", "TemperatureHigh", Me.TemperatureHigh, filename)       hs.SaveINISetting("Settings", "TemperatureLow", Me.TemperatureLow, filename)       hs.SaveINISetting("Settings", "AlternativeScheduleDeviceReference", Me.AlternativeScheduleDeviceReference, filename)   End Sub   Public Sub New(ByRef hs As Object, ByVal rootDeviceRef As Integer)       Dim lines() As String = hs.GetINISectionEx("Settings", scriptName & "_" & rootDeviceRef & ".ini")       Dim inputString = String.Join(",", lines)       'Dim rootDevice As Scheduler.Classes.DeviceClass = hs.GetDeviceByRef(rootDeviceRef)       'Dim inputString As String = rootDevice.DeviceType_Get(hs).Device_SubType_Description.ToString       Load(inputString)   End Sub   Public Sub New(ByVal inputString As String)       Load(inputString)   End Sub   Public Sub Load(ByVal inputString As String)       Dim lines() As String = inputString.Split(",")       For Each line As String In lines           Dim properties() As String = line.Split("=")           Select Case properties(0)               Case = "ExternalTemperatureSensorRef"                   Me.ExternalTemperatureSensorRef = CInt(properties(1))               Case = "TemperatureCorrectionAddition"                   Me.TemperatureCorrectionAddition = CInt(properties(1))               Case = "TemperatureCorrectionMultiplier"                   Me.TemperatureCorrectionMultiplier = CInt(properties(1))               Case = "TemperatureOffset"                   Me.TemperatureOffset = CInt(properties(1))               Case = "Log"                   Me.Log = CBool(properties(1))               Case = "HeaterDeviceReference"                   Me.HeaterDeviceReference = CInt(properties(1))               Case = "TemperatureHigh"                   Me.TemperatureHigh = properties(1)               Case = "TemperatureLow"                   Me.TemperatureLow = properties(1)               Case = "AlternativeScheduleDeviceReference"                   Me.AlternativeScheduleDeviceReference = properties(1)           End Select       Next       'HeaterDeviceReference=860,ExernalTemperatureSensorRef=521   End SubEnd Class
 

config.json for termostaten slik:

			{			"ref": "7569",			"type": "Thermostat",			"name": "Badet Termostat",			"controlRef": "7567",			"stateRef": "7567",			"temperatureUnit":"C",			"humidityRef": "362",			"heatingSetpointRef": "7568",			"coolingSetpointRef": "7568",			"uuid_base": "Thermostat7569"		},
 

Og config.ini-fila slik(med HeaterDeviceReference=6936,ExternalTemperatureSensorRef=6913, samt at 467 er fridagscriptet ditt)

[settings]ExternalTemperatureSensorRef=6913TemperatureCorrectionAddition=0TemperatureCorrectionMultiplier=1TemperatureOffset=0,3Log=FalseHeaterDeviceReference=6936TemperatureHigh=23TemperatureLow=16AlternativeScheduleDeviceReference=467[schedule]5:00=High8:00=Low13:00=High23:00=Low[AlternativeSchedule]5:30=High23:00=Low
Kjøler ned ser litt dumt ut, om jeg dropper den så står det -10 grader, så det får bare være.

 

c68474d5ec9f19e0c99cc5119e8ce2ec.png0ca6bca575e38f9c65602b1c28887a93.png5760d0f291cb6dc94cbb00f35e1ac971.png9473c2e021fc6640e33b370c2b44164c.png

Endret av gullfrode
Lenke til kommentar
Del på andre sider

  • 0

Prøver meg på et spørsmål i denne tråden:

 

Er det mulig å skape en bryter i homebridge som veklser mellom flere (felre enn 2) verdier i Homeseer?

 

I Homeseer har jeg laget en virtual device som veksler mellom ulige belysningsscener. Kunne gjerne tenkt meg muligheten til å veklse mellom disse verdiene i HomeKit (uten å måtte definere devicen som en vifte etc...)

Lenke til kommentar
Del på andre sider

Bli med i samtalen

Du kan publisere innhold nå og registrere deg senere. Hvis du har en konto, logg inn nå for å poste med kontoen din.

Gjest
Svar på spørsmålet...

×   Du har limt inn tekst med formatering.   Lim inn uten formatering i stedet

  Du kan kun bruke opp til 75 smilefjes.

×   Lenken din har blitt bygget inn på siden automatisk.   Vis som en ordinær lenke i stedet

×   Tidligere tekst har blitt gjenopprettet.   Tøm tekstverktøy

×   Du kan ikke lime inn bilder direkte. Last opp eller legg inn bilder fra URL.

×
×
  • Opprett ny...

Viktig informasjon

Vi har plassert informasjonskapsler/cookies på din enhet for å gjøre denne siden bedre. Du kan justere dine innstillinger for informasjonskapsler, ellers vil vi anta at dette er ok for deg.