MycroftAI / skill-homeassistant

Mycroft Skill/Integration for Homeassistant
GNU Lesser General Public License v3.0
114 stars 62 forks source link

Brightness support #63

Closed robertsawko closed 3 years ago

robertsawko commented 3 years ago

Many thanks for creating this skill. I've been using it with success on both individual and group lights.

It would be great if it could support brightness e.g.

Hey Mycroft, turn the corner light to 70%.
Hey Mycroft, set the corner light to 70%.

I don't think it's a high priority feature as it could be achieved with scenes. Also, most of the time people will just use an app to get a very rewarding experience of sliding. There were a few situations though when I just wanted to decrease brightness so I am sure I am not the only one.

xiki808 commented 3 years ago

+1 for this feature

Would also like to see colour change feature :) :)

Tony763 commented 3 years ago

@xiki808 hi, try set brightness of {{entity}} to {{brightnessvalue}} percent with latest commit

xiki808 commented 3 years ago

@Tony763 Thank you for your reply.

I tried that and this is what I'm getting:

image

I'm running on the latest commit: 1c0e7ba

Tony763 commented 3 years ago

@xiki808 try it with word percent, not with symbol

xiki808 commented 3 years ago

I'm giving the commands through voice @Tony763

Tony763 commented 3 years ago

and when you put it to console with text, will it work?

xiki808 commented 3 years ago

Confirmed that, when I type the command and use percent word instead of symbol, works.

Tony763 commented 3 years ago

ok, give me a moment

Tony763 commented 3 years ago

Try this branch https://github.com/Tony763/mycroft-homeassistant/tree/issue63

xiki808 commented 3 years ago

Works! Nicely done.

image

Interesting project, I'm having a look at it and hopefully I can contribute something. I'm not a python developer though and the start is a hill climb ^^

xiki808 commented 3 years ago

Would really appreciate if you can point me out where I can follow the logs printed out by self.log.debug("Entity: %s" % entity) for example.

I have venv setup and install requirements. I was hoping to tail debug logs while using mycroft.

Tony763 commented 3 years ago

You can do it wit console you already using. Start Mycroft by mycroft-star debug and supply command: :log level debug Logs are saved in /var/log/mycroft/.

But if you are using VSCode and you intent to work on skills only, use Andlo's remote skill debugger. You can set brakepoints in skills you desire to change and work is then lot easier. [https://community.mycroft.ai/t/remote-debug-skill/8012](remote debug skill). There is problem with deprecated vscode plugin, but I made a needed changes and I will send them as PR soon.

If You need future informatins, reach me by PM in https://community.mycroft.ai/

xiki808 commented 3 years ago

Got it! Thanks :)

I love logs, but that's interesting.

Tony763 commented 3 years ago

You can take step by step and see all variables and their values. For me it's like riding in Fiat versus Tesla, Give it a try. My PR should by online in few minutes.

xiki808 commented 3 years ago

Hi @Tony763, sorry for sending here, but I'm not able to send a PM from the community site.

I have added color change to lights in a new branch ( from 20.08 ) and I'm not able to push the branch due to permissions. I think since they blocked commits due to some other issues, the repo is read only.

Do you have any tips for me how I am able to push the change? Preferably without creating a fork.

Also thanks a lot for suggesting the remote debugger! Super helpful tool.

Tony763 commented 3 years ago

Hi @xiki808 You must create a fork, put changes into it and then create a Pull Request. Direct push changes to this repo is not allowed.

robertsawko commented 3 years ago

Hello, Thanks for this! Unfortunately this is still not working for me, but it looks like an issue is on homeassistant side. This is what I get on mycroft debug:

~~~~:48.498 | ERROR    |   626 | mycroft.skills.mycroft_skill.mycroft_skill:on_error:897 | An error occurred while processing a request in Home Assistant Skill
Traceback (most recent call last):
  File "/home/pi/mycroft-core/mycroft/skills/mycroft_skill/event_container.py", line 73, in wrapper
    handler(message)
  File "/opt/mycroft/skills/homeassistant.mycroftai/__init__.py", line 251, in handle_light_set_intent
    self.ha.execute_service("homeassistant", "turn_on", ha_data)
  File "/opt/mycroft/skills/homeassistant.mycroftai/ha_client.py", line 145, in execute_service
    r.raise_for_status()
  File "/home/pi/mycroft-core/.venv/lib/python3.7/site-packages/requests/models.py", line 940, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: http://192.168.0.60:8123/api/services/homeassistant/turn_on

The standard turn on/off works ok though. Would you be able to advise?

Tony763 commented 3 years ago

Hello @robertsawko, which version of HA skill You are using?

robertsawko commented 3 years ago

Sorry, I am still relatively new to mycroft. I have navigated to mycroft-core/skills/homeassistant.mycroftai. git branch is telling me I am on 20.08 and the last commit appears to be 985c4013205d0ef3a55fc7aa3859f52cf1796e9b.

Tony763 commented 3 years ago

Its quite old commit, current development from there is still not a part of official release as there are some collision with other skills namely issue #64. You can try to remove original directory and get skill from there with mycroft-msm install https://github.com/MycroftAI/skill-homeassistant. See Mycroft Skill manager

robertsawko commented 3 years ago

Thanks, I didn't know about mycroft-msm. I think I was installing skills via the web integration (official release?). Can I just confirm what I need to do? I am on picroft so:

source mycroft-core/venv-activate.sh
mv mycroft-core/skills/homeassistant.mycroftai/ old-haas-skill
./mycroft-core/bin/mycroft-msm install https://github.com/MycroftAI/skill-homeassistant

and if things are incompatible I can revert using old-haas-skill?

Tony763 commented 3 years ago

Yes, you should be fine this way. Just make sure that "old-haas-skill" is not present in skill directory. This way You will get actual active branch with latest commit in it.

Second option is to use just git clone and pick which branch or commit you want.

robertsawko commented 3 years ago

Great. Thanks, it's working. Although now I seem to have this problem that appears to be described above, but I think I've got it the other way around. If I type percent in the terminal it works, but when I speak to Mr M % is picked up and Mr M is confused.

Tony763 commented 3 years ago

Put there screenshots of terminal with all these uterances, I will look into it.

robertsawko commented 3 years ago

Thanks for all of your quick replies. Here's a screenshot. Both typed in, but when I speak I get the latter:

brighness

Tony763 commented 3 years ago

Try it with white space between 50 and %.

robertsawko commented 3 years ago

I tried and it's the same. I also tried dots at the end.

robertsawko commented 3 years ago

Funnily enough:

set the brightness of kitchen to 60percent

works just fine.

Tony763 commented 3 years ago

I see it now, PR fixing this issue is still not merged as it waiting for me to fix tests for it. I missed notification. I will add them tonigh and ask to merge it.

robertsawko commented 3 years ago

Just to let you know I have temporarily edited the entry in the intent files and it is working fine. Will patiently wait for the PR to be accepted.

Tony763 commented 3 years ago

Hi @robertsawko, PR was merged. If you could, check it and if it's ok, close the issue, please.

robertsawko commented 3 years ago

Thanks! I run

/mycroft-core/bin/mycroft-msm update https://github.com/MycroftAI/skill-homeassistant

and I can confirm that the % symbol is being picked up and it works as expected.