Giter VIP home page Giter VIP logo

Comments (4)

dacarson avatar dacarson commented on July 17, 2024

I have made this work with two changes:

  1. Add the logging to index.js:277
    lux: accessory.LightLevelService ? accessory.LightLevelService.getCharacteristic(Characteristic.CurrentAmbientLightLevel).value : accessory.CurrentConditionsService.getCharacteristic(Characteristic.CurrentAmbientLightLevel).value

  2. Switch from 'weather' to 'custom', in currentConditions.js:151 but also do this:

	this.services = [this.CurrentConditionsService];
	this.historyService = new FakeGatoHistoryService("custom", this, this.config.fakegatoParameters);
	this.services = this.getServices();

The 2nd part doesn't seem right. When examining the code in FakeGato, it looks at all the Services that are part of the Accessory. And then for each Characteristic of each Services it checks to see if it can create a history entry for it. If so, it does.

The challenge is the historyService is part of the Accessory and if I don't override the value of this.service it crashes. It crashes because when it walks the list of Services, it reaches the historyService which is undefined at that moment.

I'm wondering if there is different way Services should be registered with the Accessory.

from homebridge-weather-plus.

dacarson avatar dacarson commented on July 17, 2024

This is what it currently looks like:
IMG_4935

from homebridge-weather-plus.

dacarson avatar dacarson commented on July 17, 2024

Worked out an elegant fix. Following the pattern in index.js that has an array of Accessories:
this.accessoriesList = [];

In currentConditions.js, create an array of services, aka this.services = [];
Then add each Service as they are created, aka:
this.services.push(this.CurrentConditionsService);
later
this.services.concat(compatibility.getServices(this));
and later:
this.services.push(this.informationService);
and lastly do this:

	this.historyService = new FakeGatoHistoryService("custom", this, this.config.fakegatoParameters);
	this.services.push(this.historyService);

Change getServices() function to just return the services object:

	getServices: function ()
	{
		return this.services;
	}

This way, only fully defined Service objects exist in the services array. FakeGatoHistoryService is now happy.

from homebridge-weather-plus.

wimleers avatar wimleers commented on July 17, 2024

Very interesting!

from homebridge-weather-plus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.