Giter Club home page Giter Club logo

Comments (16)

asantaga avatar asantaga commented on June 11, 2024 1

good point... I'll investigate into this over xmas..

I do need to get the damm thing into the main branch of HA.....

Changing task name

from wiserhomeassistantplatform.

asantaga avatar asantaga commented on June 11, 2024

Looking at the openhab impl this can be done by using the following patch command
"{"RequestOutput":"" + (outputState ? "On" : "Off") + ""}";

I smell a major enhancement coming on :-)

"data/domain/SmartPlug/ is the endpoint

from wiserhomeassistantplatform.

asantaga avatar asantaga commented on June 11, 2024

next on the list. :-)

from wiserhomeassistantplatform.

asantaga avatar asantaga commented on June 11, 2024

opened base bug asantaga/wiserheatingapi#11

from wiserhomeassistantplatform.

asantaga avatar asantaga commented on June 11, 2024

This is now implemented in branch R1.9Dev. There is still a sync issue so leaving this open but it fundamentally works

from wiserhomeassistantplatform.

asantaga avatar asantaga commented on June 11, 2024

Fixed this by forcing the state to be refreshed, seams to work

Line 155 of init.py
self.wiserhub.refreshData()

@msp1974 Is this truely bad in the async world?

from wiserhomeassistantplatform.

msp1974 avatar msp1974 commented on June 11, 2024

Only in the fact you are doing 2 updates one after another. The line after does force an update. The nothrottle=true means it does immediately. I just got one of these plugs tonight and have been looking at it.

Issue you are having is a timing one. When you set the plug to on, there seems to be a delay while the plug actually turns on before the hub reports it as on. Guessing the 2 updates is enough time for this to show correct state. If anything i would copy line 156 twice to see if this works. Alternetive cheat would be to add a small delay using await sleep but think this is frowned upon in HA.

I will have a look at this over weekend and see if there is a better approach.

from wiserhomeassistantplatform.

msp1974 avatar msp1974 commented on June 11, 2024

Also, would be tempted not to call this method set mode as the plug actually has a mode of manual or auto and you can set a schedule on it. Maybe set plug state?

from wiserhomeassistantplatform.

asantaga avatar asantaga commented on June 11, 2024

Mm

A) re uodate i suppose i could just issue the update without doing a async call... maybe a very short sleep is the right approach. I could make the sleep itself async so that it relinquishs control back to HA thread

B) ya right there are different modes but i wonder if that should be a api call. So we would have set state and set mode

C) need to implement schedule too....

Finally. Dude u up late as well!!!

from wiserhomeassistantplatform.

msp1974 avatar msp1974 commented on June 11, 2024

Researching some docs, think the right way to do this is as below:
await asyncio.sleep(1)
Time in brackets is in seconds. Think 1 second is more than enough time for this to update to the right status before doing a refresh with async_update. I'll give it a try tonight and see how it works.

Always up late! Only time to get things done! ;-)

from wiserhomeassistantplatform.

msp1974 avatar msp1974 commented on June 11, 2024

Have also noticed that we (he says 'we' like it wasn't his poor coding! )are calling the forced refresh twice when setting away mode and switches. Once in the switch.py file and once in init.py when calling api. Prob shouldn't do this given feedback on stability issues with hub of requesting updates from it too often. Will try and sort tonight or over weekend.

from wiserhomeassistantplatform.

msp1974 avatar msp1974 commented on June 11, 2024

So been playing with this tonight to see if adding a delay works and what length. Seem to have settled on yes this does work and about 0.5 secs does ok. However, seen some very strange behaviour from my brand new smartplug!

Firstly, the 'OutputState' value disappears from the returned json when querying it (seen through Postman) when in an On state. Shows when in off state. There is however and manual state that shows instead which you can test with.

Also, if I turn on, it can stay on for 5 seconds and then turn itself off then on then off again within a couple of seconds. Positive there is nothing being sent from HA. Have you seen anything like this with yours? Not sure if this has updated firmware during today as seemed fine yesterday.

from wiserhomeassistantplatform.

asantaga avatar asantaga commented on June 11, 2024

Weird thing about the smart plug missing json attributes.. I'll also confirm on myside and see which is the more reliable attribute for checking the status..

I'll add the await asyncio.sleep(1) to the method and confirm it works fine.

Side note : Like you , totally swamped during the weekdays and only late at night can I do some coding, alas I have a conference next week, a house I need to clean up so not sure how much time I'll get... joys of work , home life and a 4yr old ever wanting attention.....

from wiserhomeassistantplatform.

Fulch avatar Fulch commented on June 11, 2024

Have not tried HA control of plug yet (waiting for you guys to "do your thing" with the code first) but using the Android wiser app or the button on the plug mine is behaving fine.

Firefox Rested extension displays the expected json response and plug stays 'on' or 'off' as instructed!

from wiserhomeassistantplatform.

asantaga avatar asantaga commented on June 11, 2024

merged it in so its ready for testing.

from wiserhomeassistantplatform.

asantaga avatar asantaga commented on June 11, 2024

#62 merged into 1.9Dev

from wiserhomeassistantplatform.

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.