RomRider / ha_nicehash

💵 Custom NiceHash integration for Home-Assistant
MIT License
36 stars 13 forks source link

Per device switches #18

Closed ivanpavlina closed 2 years ago

ivanpavlina commented 3 years ago

Hi, i added switches per device, it works great from my side (i need to turn on / off certain mining devices thoughout the day). Also theres attributes set to the switches, i did not create new device sensors in the component, I'm using templates to do that in homeassistant. If you want to feel free to merge it.

Hukuma1 commented 2 years ago

Exactly what I was looking for. Having only one power switch for all devices is quite limiting. Thank you!

However, once I turn off the power to one device, it goes unavailable and I am unable to turn it back on. Is there a way to toggle it back on? And also, would it be possible to switch the power profiles as well? Right now if you toggle it off, and then manually toggle it back on (via the website), it only turns it on. It does not remember the optimize profile (manual, lite, medium, high).

unavail

Edit: HA Logs say this:

Logger: homeassistant.helpers.entity
Source: helpers/entity.py:549
First occurred: 1:41:46 PM (2 occurrences)
Last logged: 1:41:46 PM

Entity switch.nh_pc_geforce_rtx_3070_power (<class 'custom_components.nicehash.switch.NiceHashDeviceSwitch'>) implements device_state_attributes. Please report it to the custom component author.
Entity switch.nh_pc_geforce_rtx_3070_power_2 (<class 'custom_components.nicehash.switch.NiceHashDeviceSwitch'>) implements device_state_attributes. Please report it to the custom component author.
Hukuma1 commented 2 years ago

Switching out device_state_attributes for extra_state_attributes fixed the HA log error. Apparently got deprecated a while back as per: https://github.com/home-assistant/core/pull/47304

ivanpavlina commented 2 years ago

However, once I turn off the power to one device, it goes unavailable and I am unable to turn it back on. Is there a way to toggle it back on?

Are you talking about toggle in NiceHash app? With that you are disabling the device and it goes unavailable as expected, you should use play/stop buttons then device remains enabled but stopped. Everything works great from my side.

And also, would it be possible to switch the power profiles as well?

Uhh, this is my first time hearing about power profiles, I can look into it when I'll find the time.

Switching out device_state_attributes for extra_state_attributes fixed the HA log error. Apparently got deprecated a while back as per: home-assistant/core#47304

I will integrate it into this PR but I don't know if this will ever get pushed to this repo, it seems RomRider stop developement of this component.. When this PR gets finished with above stuff I'll email him so it hopefully gets merged.

Hukuma1 commented 2 years ago

Are you talking about toggle in NiceHash app? With that you are disabling the device and it goes unavailable as expected, you should use play/stop buttons then device remains enabled but stopped. Everything works great from my side.

I'm not, I'm talking about the switch that's created. Am I using it incorrectly? Entity ID: switch.nh_pc_geforce_rtx_3070_power

toggle

Power profiles are super important. Will help your hashrate and/or power efficiency. It's basically a tuned profile if you didn't manually tune your cards already. ;)

Edit: The profiles come with QuickMiner. Maybe this is why I'm getting different behavior as well? https://github.com/nicehash/NiceHashQuickMiner

ivanpavlina commented 2 years ago

Could be, I need to test this, I don't use quickminer, give me a couple of days.

Hukuma1 commented 2 years ago

This would hopefully open the door to something that Nicehash still has not added. A way to schedule their "Game Mode." e.g. I want to run fans at 100% during the day, and cut fans down to 60% at night for less noise.

ivanpavlina commented 2 years ago

I think thats it.

Warnings for extra_state_attributes are fixed.

Switches will remain active when stopping with QuickMiner (QuickMiner works differently than regular Miner, it disables the devices while regular Miner just stops it... Oh well)

For power mode toggle I added new service set_power_mode which receives RigName, DeviceName and PowerMode which to set (allowed values for PowerMode are HIGH / MEDIUM / LOW )

You can get RigName and Device name from device attributes: 1 2

Also devices have new attribute powerMode to check which powerMode is currently set.

I have tested new version with both regular Miner and QuickMiner, looks good, let me know how it looks from your side.

Hukuma1 commented 2 years ago

Thanks so much for this! Testing it out right now. Right off the bat, it seems the profiles being applied are mismatched.

I run the nicehash.set_power_mode service and then check Nicehash webui.

HIGH = Medium MEDIUM = Lite LOW = Not optimized/no profile

Also I got two cards in the system, that both show up as GeForce RTX 3070. So not sure how to run the power service for 2nd card for instance if needed.

Also like in your screenshot above, does the powerMode: LOW always stay as that? Or does it actually update on the actual value? Mine seems to be stuck with LOW no matter what. But also it seems my stats are being reported wacky.

rig_name: PC
device_name: GeForce RTX 3070
temperature: 5570633
load: 6553700
fan_speed: 3751
fan_speed_percentage: 100
powerUsage: 133
powerMode: LOW
friendly_name: NH - PC - GeForce RTX 3070 - Power
card2

For the power switch once I switch it off, I see the toggle turn off, then turn on a few seconds later, and then turn off again. Perhaps this is intended behavior in that it stops the device and then clears the power profile to nothing (not optimized). Maybe the switch it triggered into the on position for the profile change?

However, if I turn it back on, the power profile is reset to not optimized instead of using the last used setting (e.g. high).

In case it matters, using the latest v0.5.3.3 RC of QuickMiner.

ivanpavlina commented 2 years ago

Right off the bat, it seems the profiles being applied are mismatched.

I run the nicehash.set_power_mode service and then check Nicehash webui.

HIGH = Medium MEDIUM = Lite LOW = Not optimized/no profile

Uhh, weird , API docs mention only HIGH MEDIUM and LOW as powerMode values. (here: https://www.nicehash.com/docs/rest/-hashpower-private , at POST /main/api/v2/minig/rigs/status2)

Integration is doing request with correct values but it seems somewhere internally in nicehash it is mismatching actual power modes. Theres seems to be a way to workaround this, but I will have to look into if it can be integrated here (see here: https://github.com/nicehash/rest-clients-demo/issues/38)

Also I got two cards in the system, that both show up as GeForce RTX 3070. So not sure how to run the power service for 2nd card for instance if needed.

You can't, I'm a poor peasant with one card and didn't think of this :D I will modify the script to use deviceId and show current deviceId in device attribute which you can use for service call.

Also like in your screenshot above, does the powerMode: LOW always stay as that? Or does it actually update on the actual value? Mine seems to be stuck with LOW no matter what. But also it seems my stats are being reported wacky.

Yup, you're right, I have a bug, I'll fix it.

For the power switch once I switch it off, I see the toggle turn off, then turn on a few seconds later, and then turn off again. Perhaps this is intended behavior in that it stops the device and then clears the power profile to nothing (not optimized). Maybe the switch it triggered into the on position for the profile change?

I will have to look into this, there's weird sleeps in the code after toggling the switches which results in this wacky behaviour. EDIT: okay, sleeps are there because nicehash api is slow to return new values, dev already did a workaround for this... Nothing more I can do.

However, if I turn it back on, the power profile is reset to not optimized instead of using the last used setting (e.g. high).

This is probably default behaviour of nicehash, integration is not doing anything to powerMode when you toggle the switch. You will have to call service set_power_mode when device turned on. Automation inside homeassistant should take care of that.

Hukuma1 commented 2 years ago

Yeah, looks like NH is having some... issues haha.

Without overloading you, is there a way to expose the fan values as an entity? fan_speed: / fan_speed_percentage: So we can push a custom fan speed for our cards? Or ultimately all the values TDP, MEMORY, etc. I suppose that'll unlock full potential if people wanted to OC and setup custom profile.

No worries on the power switch sleep stuff. I think a simple automation that checks the powerMode: value and then use your new nicehash.set_power_mode service should do the trick.

Hopefully this also gets merged as this takes this integration into a whole new level!

ivanpavlina commented 2 years ago

Okay, jeez, I can't look at the code anymore :D Enough for today.

While running QuickMiner API actually returns data which we can use for setting correct power modes. Now the device has attribute supported_power_modes and it is dynamically populated from info API provided. There's actually multiple different modes depending on the card you are running. I hope we are bulletproof now with QuickMiner, atleast for powerMode.

Service is now called with rig_id and device_id which are present in attributes. power_mode doesn't have any static limits, supported modes are calculated dynamically, atleast for QuickMiner devicess. Let me know if its okay from your side now.

Yeah, looks like NH is having some... issues haha.

Yeah, tell me about it. Wish they made API which consolidates two different apps... Or that they did one app with all functionality from the start lol.

Without overloading you, is there a way to expose the fan values as an entity? fan_speed: So we can push a custom fan speed for our cards? Or ultimately all the values TDP, MEMORY, etc. I suppose that'll unlock full potential if people wanted to OC and setup custom profile.

Are you are talking about making API requests to change FAN/TDP/MEMORY values or to just expose new sensor entities? If its the latter you can create custom entities from attributes, homeassistant has that covered. But if you're talking about calling API and changing those values, I have no idea, I didn't see anything about that in API docs, I'll check it out. But still, NiceHashQuickMiner profiles have those values automatically optimized with different power modes.

Hukuma1 commented 2 years ago

Works great! Thank you!

rig_name: PC
rig_id: 0-fjAnDhFjhb7JusCa2AA46g
device_name: GeForce RTX 3070
device_id: 0
temperature: 6553687
load: 6553700
fan_speed: 3753
fan_speed_percentage: 100
power_usage: 143
power_mode: HIGH
supported_power_modes: HIGH, MEDIUM, LITE
friendly_name: NH - PC - GeForce RTX 3070 - Power

For the fan stuff, yeah, to change it. Unless you think it's possible/easier to add a "custom" powerMode setting? That way we can edit the optimize json file ourselves and simply call our custom "id:" 9? (instead of just HIGH/MEDIUM/LITE)

e.g.

{ "name": "GeForce RTX 3070", "op": [
      { "id": 9, "pt": 0, "dmc": 1370, "mcc": 1110, "fm": 3, "ftg" : 75, "ftr": 75, "lhr": [33, 72]},
      { "id": 3, "pt": 0, "dmc": 1370, "mcc": 1110, "fm": 3, "ftg" : 56, "ftr": 68, "lhr": [33, 72]},
      { "id": 2, "pt": 0, "dmc": 1170, "mcc": 1065, "fm": 3, "ftg" : 58, "ftr": 70, "lhr": [33, 72]},
      { "id": 1, "pt": 0, "dmc": 900, "mcc": 810, "fm": 3, "ftg" : 62, "ftr": 72, "lhr": [33, 72]}
pt = Profile Type
dmc = Delta Memory Clock
mcc = Max Core Clock (Absolute)
fm = Fan Mode
ftg = Fan Target GPU Temp
ftr = Fan Target (V)Ram Temp
ivanpavlina commented 2 years ago

Works great! Thank you!

rig_name: PC
rig_id: 0-fjAnDhFjhb7JusCa2AA46g
device_name: GeForce RTX 3070
device_id: 0
temperature: 6553687
load: 6553700
fan_speed: 3753
fan_speed_percentage: 100
power_usage: 143
power_mode: HIGH
supported_power_modes: HIGH, MEDIUM, LITE
friendly_name: NH - PC - GeForce RTX 3070 - Power

For the fan stuff, yeah, to change it. Unless you think it's possible/easier to add a "custom" powerMode setting? That way we can edit the optimize json file ourselves and simply call our custom "id:" 9? (instead of just HIGH/MEDIUM/LITE)

e.g.

{ "name": "GeForce RTX 3070", "op": [
      { "id": 9, "pt": 0, "dmc": 1370, "mcc": 1110, "fm": 3, "ftg" : 75, "ftr": 75, "lhr": [33, 72]},
      { "id": 3, "pt": 0, "dmc": 1370, "mcc": 1110, "fm": 3, "ftg" : 56, "ftr": 68, "lhr": [33, 72]},
      { "id": 2, "pt": 0, "dmc": 1170, "mcc": 1065, "fm": 3, "ftg" : 58, "ftr": 70, "lhr": [33, 72]},
      { "id": 1, "pt": 0, "dmc": 900, "mcc": 810, "fm": 3, "ftg" : 62, "ftr": 72, "lhr": [33, 72]}
pt = Profile Type
dmc = Delta Memory Clock
mcc = Max Core Clock (Absolute)
fm = Fan Mode
ftg = Fan Target GPU Temp
ftr = Fan Target (V)Ram Temp

Hmm it seems there is a way to achieve that, I guess you visited this page but let it remain for reference: https://www.reddit.com/r/NiceHash/comments/nnvr9b/workaround_for_missing_quickminer_optimization/

You could try to add custom profile and see how everything works, if its visible from NiceHash website it should appear in supported_power_modes. Let me know if and when you try it

Hukuma1 commented 2 years ago

Oh wow, just had a moment of lol. It works!

fan_speed_percentage: 75
power_usage: 143
power_mode: NIGHTMODE
supported_power_modes: NIGHTMODE, HIGH, MEDIUM, LITE

Thanks so much! :)

nhweb

Even shows up under the WebUI. A slightly longer name, but hey it works.

ivanpavlina commented 2 years ago

Awesome! Now to tidy up a code a bit and to get dev to merge it

Hukuma1 commented 2 years ago

power_mode: UNKNOWN if profile is set to Manual, not sure if NH discerns or shows that somewhere internally. If the device is off/disabled the power mode is also set to the same UNKNOWN state.

It seems while we can make a new profile, I can't seem to find out a way to cap the fan speed.

"fm": 3 = Fan Mode 3

Those seem to correspond with the OC Tuner fan settings from the drop down box which seem to be:

0 = Default/Auto 1 = Fixed Speed 2 = Target GPU Temp 3 = Target GPU&VRAM/Hotspot T. (default) 4 = Target plus decrease MCC

Setting fm: 1 sounds great, but I have no way of changing the max fan speed of -1 (which means they could spin up to 100%). I'm not a coder, so I'm not sure if it's possible to pass on other variables in the fm: 1 setting? like fm: 1, 60. Trying to cap fans to run at 60% max. Is there a way to test if it accepts other info in that fan setting?

ivanpavlina commented 2 years ago

There are these lines in OCtune

dda[pname].smartfan.mode = devdata[k].fm;
dda[pname].smartfan.fixed_speed = devdata[k].fs;

In your profile try setting fm: 1 -> Fixed Speed and fs: 60 -> 60%

For reference here are all the lines:

dda[pname].pname = pname;
dda[pname].ptype = devdata[k].pt;
dda[pname].ram_maker = devdata[k].rm;
dda[pname].oc.delta_mem_clock = devdata[k].dmc;
dda[pname].oc.max_core_clock = devdata[k].mcc;
dda[pname].oc.delta_core_clock = devdata[k].dcc;
dda[pname].oc.power_limit = devdata[k].pl;
dda[pname].oc.max_core_volt = devdata[k].mcv;
dda[pname].oc.memory_timings = devdata[k].mt;
dda[pname].smartfan.mode = devdata[k].fm;
dda[pname].smartfan.fixed_speed = devdata[k].fs;
dda[pname].smartfan.target_gpu = devdata[k].ftg;
dda[pname].smartfan.target_vram = devdata[k].ftr;
dda[pname].smartfan.level_max = devdata[k].flmax;
ivanpavlina commented 2 years ago

power_mode: UNKNOWN if profile is set to Manual, not sure if NH discerns or shows that somewhere internally.

Hmm, weird, can you please pull new version of the integration, I added additional debug logging. After that set this components logs to debug - in configuration.yaml set this to logger->

logger:
  default: info
  logs:
    custom_components.nicehash: debug

Restart homeassistant, make sure youre getting UNKNOWNpowerMode while you're on MANUALmode and in homeassistant logs find the line starting with API Rigs response:, please paste it here, that's raw API response.

If the device is off/disabled the power mode is also set to the same UNKNOWN state.

When device is disabled its normal to show UNKNOWN, API doesn't send any information about currently set profile.

ivanpavlina commented 2 years ago

Nevermind, managed to replicate it here, manual has ID 0 always and its not send as normal powerMode (which makes sense). Fixing it now.

EDIT: Done, try it now.

Hukuma1 commented 2 years ago

So cool. Thank you! If someone finds this thread via Google, QuickMiner optimize profiles accept additional parameters just fine. e.g.

    { "name": "GeForce RTX 3070", "op": [
      { "id": 9, "pt": 0, "dmc": 1170, "mcc": 1065, "fm": 1, "flmax": 60, "fs": 30, "ftg" : 83, "ftr": 85, "lhr": [33, 72]},
      { "id": 3, "pt": 0, "dmc": 1370, "mcc": 1110, "fm": 3, "ftg" : 56, "ftr": 68, "lhr": [33, 72]},

New profile (id: 9) sets fixed fan to be running at 30% and no more than 60%.

RomRider commented 2 years ago

I don't have anything to test at the moment, so I'll just review the code from a technical perspective. One comment is consistency with the " (you're using sometimes ')

Once you've tidied everything up, I'm going to review and merge that! Thanks for the work 🙏

ivanpavlina commented 2 years ago

One comment is consistency with the " (you're using sometimes ')

Sure

Once you've tidied everything up, I'm going to review and merge that! Thanks for the work 🙏

Awesome, thanks, Ill let you know when Im done.

Hukuma1 commented 2 years ago

today at 11:05:59 AM2022-01-25 11:05:59 DEBUG (MainThread) [custom_components.nicehash.common] API Rigs response: {'minerStatuses': {'MINING': 1}, 'rigTypes': {'MANAGED': 1}, 'totalRigs': 1, 'totalProfitability': 6.912000000000002e-05, 'groupPowerMode': 'UNKNOWN', 'totalDevices': 1, 'devicesStatuses': {'DISABLED': 2, 'MINING': 1}, 'unpaidAmount': '0.00000284', 'path': '', 'btcAddress': 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'nextPayoutTimestamp': '2022-01-25T20:00:00Z', 'lastPayoutTimestamp': '2022-01-25T17:00:36.454Z', 'miningRigGroups': [], 'miningRigs': [{'rigId': '0-foH7VpkqsUyJusCa2AA46g', 'type': 'MANAGED', 'name': 'PC', 'statusTime': 1643137553440, 'joinTime': 1643135344, 'minerStatus': 'MINING', 'groupName': '', 'unpaidAmount': '0.00000284', 'softwareVersions': 'NHQM_v0.5.3.3,Excavator_v1.7.6.2_Build_998', 'devices': [{'id': '32', 'name': 'AMD Ryzen 9 5900X 12-Core Processor', 'deviceType': {'enumName': 'CPU', 'description': 'CPU'}, 'status': {'enumName': 'DISABLED', 'description': 'Disabled'}, 'temperature': -1.0, 'load': 2.0, 'revolutionsPerMinute': -1.0, 'revolutionsPerMinutePercentage': -1.0, 'powerMode': {'enumName': 'UNKNOWN', 'description': 'Unknown'}, 'powerUsage': -1.0, 'speeds': [], 'intensity': {'enumName': 'LOW', 'description': 'Low power mode'}, 'nhqm': ''}, {'id': '0', 'name': 'GeForce RTX 3070', 'deviceType': {'enumName': 'NVIDIA', 'description': 'Nvidia'}, 'status': {'enumName': 'MINING', 'description': 'Mining'}, 'temperature': 6750299.0, 'load': 6553700.0, 'revolutionsPerMinute': 3750.0, 'revolutionsPerMinutePercentage': 100.0, 'powerMode': {'enumName': 'UNKNOWN', 'description': 'Unknown'}, 'powerUsage': 217.0, 'speeds': [{'algorithm': 'DAGGERHASHIMOTO', 'title': 'DaggerHashimoto', 'speed': '50.85000000', 'displaySuffix': 'MH'}], 'intensity': {'enumName': 'LOW', 'description': 'Low power mode'}, 'nhqm': 'V=1;CCC=1854;CVC=993;MCC=6801;MCS=6801;MT=213;PLW=220;KTUMED=67978;OP=0;OPA=NightMode:9,High:3,Medium:2,Lite:1;'}, {'id': '1', 'name': 'GeForce RTX 3070', 'deviceType': {'enumName': 'NVIDIA', 'description': 'Nvidia'}, 'status': {'enumName': 'DISABLED', 'description': 'Disabled'}, 'temperature': 4259894.0, 'load': 0.0, 'revolutionsPerMinute': 999.0, 'revolutionsPerMinutePercentage': 30.0, 'powerMode': {'enumName': 'UNKNOWN', 'description': 'Unknown'}, 'powerUsage': 11.0, 'speeds': [], 'intensity': {'enumName': 'LOW', 'description': 'Low power mode'}, 'nhqm': 'V=1;CCC=6;CVC=668;MCC=6801;MCS=6801;MT=183;PLW=220;KTUMED=55789;OP=0;OPA=NightMode:9,High:3,Medium:2,Lite:1;'}], 'cpuMiningEnabled': False, 'cpuExists': True, 'stats': [{'statsTime': 1643137531000, 'market': 'USA_E', 'algorithm': {'enumName': 'DAGGERHASHIMOTO', 'description': 'DaggerHashimoto'}, 'unpaidAmount': '0.00000284', 'difficulty': 0.2531821781400082, 'proxyId': 4, 'timeConnected': 1643135346458, 'xnsub': True, 'speedAccepted': 69.54601299791139, 'speedRejectedR1Target': 0.0, 'speedRejectedR2Stale': 0.0, 'speedRejectedR3Duplicate': 0.0, 'speedRejectedR4NTime': 0.0, 'speedRejectedR5Other': 0.0, 'speedRejectedTotal': 0.0, 'profitability': 6.912000000000002e-05}], 'profitability': 6.912000000000002e-05, 'localProfitability': 5.1680121365050733e-05, 'rigPowerMode': 'UNKNOWN', 'v4': {'versions': [], 'mdv': {'state': 0}, 'mmv': {'targetState': 0, 'workerName': ''}, 'osp': [], 'odp': [], 'omp': [], 'actions': [], 'devices': []}}], 'rigNhmVersions': ['NHQM_v0.5.3.3,Excavator_v1.7.6.2_Build_998'], 'externalAddress': False, 'totalProfitabilityLocal': 5.1680121365050733e-05, 'pagination': {'size': 25, 'page': 0, 'totalPageCount': 1}} today at 11:05:59 AM2022-01-25 11:05:59 DEBUG (MainThread) [custom_components.nicehash.common] Finished fetching nicehash data in 0.465 seconds (success: True)

It still sticks to UNKNOWN if in Manual profile. If I switch it to another profile, it changes, but in the logs it still says UNKNOWN for some reason? I had 2 disabled devices when I ran this test if it matters (CPU and another 3070).

Edit: I mean the attribute changes and shows different power_mode e.g. HIGH, but if I set to manual, it goes to UNKNOWN.

ivanpavlina commented 2 years ago

It still sticks to UNKNOWN if in Manual profile. If I switch it to another profile, it changes, but in the logs it still says UNKNOWN for some reason? I had 2 disabled devices when I ran this test if it matters (CPU and another 3070).

Edit: I mean the attribute changes and shows different power_mode e.g. HIGH, but if I set to manual, it goes to UNKNOWN.

Weird, are you sure you're running latest version? From the message you posted attribute powerMode should be set to MANUAL - Its calculated from this kv pair: 'nhqm': 'V=1;CCC=1854;CVC=993;MCC=6801;MCS=6801;MT=213;PLW=220;KTUMED=67978;OP=0;OPA=NightMode:9,High:3,Medium:2,Lite:1;' OP=0 means MANUAL

I ran your nhqm string through the standalone parser and I get MANUAL value, it should work.

ivanpavlina commented 2 years ago

Hey @RomRider , what do you say about changing UPDATE_INTERVAL from minutes to seconds? It could allow for nicer graphs, personally I would like to run it every 30 seconds max.

Hukuma1 commented 2 years ago

Pretty sure I am. Copied the 7 raw files over to overwrite previous stuff. Confirming I see supported_power_modes.append('MANUAL') in common.py. It just seems to time out and default back to UNKNOWN if I switch to MANUAL. Switching the profiles using NiceHash's webGui if it matters?

RomRider commented 2 years ago

Hey @RomRider , what do you say about changing UPDATE_INTERVAL from minutes to seconds? It could allow for nicer graphs, personally I would like to run it every 30 seconds max.

I'd suggest to introduce a parameter for that instead. If you'd like to go this way, please open another PR as this one has become quite big already :)

ivanpavlina commented 2 years ago

Pretty sure I am. Copied the 7 raw files over to overwrite previous stuff. Confirming I see supported_power_modes.append('MANUAL') in common.py. It just seems to time out and default back to UNKNOWN if I switch to MANUAL. Switching the profiles using NiceHash's webGui if it matters?

No idea why it doesn't work for you, I tried all combinations, I always get correct powerMode attribute. I rewritten parser, service now allows to pick switch entity as hass intended... Try it, let me know if it has fixed your problems.

Hukuma1 commented 2 years ago

It works! I guess for whatever reason, I never saw MANUAL under supported modes before. Now it's there and I also see it switching off to that if I choose it. Thanks!

power_mode: MANUAL
supported_power_modes: NIGHTMODE, HIGH, MEDIUM, LITE, MANUAL
ivanpavlina commented 2 years ago

Awesome! @RomRider code should be ready for review, let me know if it looks good from your side.

RomRider commented 2 years ago

@ivanpavlina, do you think we could have a select entity instead of a new service for the power mode feature?

ivanpavlina commented 2 years ago

@ivanpavlina, do you think we could have a select entity instead of a new service for the power mode feature?

I thought about it but i didn't find any examples how to do it, plus afaik preferred way in homeassistant is to have entity behaviour is to call service with entity mapped to it.

https://developers.home-assistant.io/docs/dev_101_services/

Entity Services
Sometimes you want to provide extra services to control your entities. For example, the Sonos integration provides services to group and ungroup devices. Entity services are special because there are many different ways a user can specify entities. It can use areas, a group or a list of entities.

You need to register entity services in your platforms, like <your-domain>/media_player.py. These services will be made available under your domain and not the media player domain.
ivanpavlina commented 2 years ago

Also, in closed PR #10 @qcasey implemented fix for load and temperature values, I'm gonna implement that here, but I'll leave it in device switch attributes only

Edit: Done

Hukuma1 commented 2 years ago
rig_name: PC
device_name: GeForce RTX 3070
temperature: 66
load: 100
fan_speed: 3753
fan_speed_percentage: 100
power_usage: 133
power_mode: HIGH
supported_power_modes: NIGHTMODE, HIGH, MEDIUM, LITE, MANUAL
friendly_name: NH - PC - GeForce RTX 3070 - Power

Works great, thanks!

Hukuma1 commented 2 years ago

Can this please be merged? Been working great for 6 months without any problems. :)

ivanpavlina commented 2 years ago

A bit late but... happy birthday to #18 :)

@RomRider can you please merge this, can also confirm everything works without problems.

RomRider commented 2 years ago

Thanks :)