Smartly Inject

Simon added that when we had to manually copy the changes and paste them into the JavaScript page in the dashboard manually, and then save it.

His modification automated getting the changes onto the clipboard for pasting.

1 Like

Looks like you don't need to change the name of the files, you can just tweak the driver where is references the usermode.json file. I'll post on the other thread.

2 Likes

The thread that dana linked to earlier?

1 Like

Yep.

2 Likes

If I get time I might try and unpick some of the references to my hacked .js file around here and remove it from my repository. It's no longer needed and just makes things more confusing. Markus was happy for me to take this over, so if I do that, I can fix the driver. But I'm not in any rush.

3 Likes

I deleted the 3 renamed files I uploaded from above, then modified Markus' driver to point to usermode.json as you posted in the other thread. They all work and I do not get the copied to clipboard message.

EDIT.. Spoke to soon. I had to add them back.

1 Like

You'll need to refresh the Smartly Inject device. This is a bit tricky.... You can either create a new device and add that to your dashboards, or setup a dummy RM rule to include an action to refresh the existing device.

Ok weird stuff happening, went to open smartly virtual device and get a big dark scree "loading layout"

Rebooting..

No, that's normal.

That's why the refresh is tricky....

Oh wierd I was into that device earlier and it loaded and I refreshed it. Hmm

If it was in a state where the files were not named correctly or the same as what it was expecting, or you had only just created the device, then it would display "correctly", once it is "working", then it will display with the dark screen.

The reason for it is, in order for it to work how it does when the tile is added to the dashboard, it is messing with the web page that is the dashboard, essentially "injecting" the javascript and css from the files, plus a few other bits and pieces. This is done using the javascript attribute from the device, the one you reference when creating the tile. When you are in the Device Details screen, Hubitat is attempting to display the attributes of the device, including the javascript one. The "injection" process does not make sense on this screen, so it plays havoc with the display of the device. It doesn't cause any issues, just with the display of the page. If you need to open the device and not interact with it too much, you can disable it first in the device list before opening the device details page. you mostly just lose visibility of attributes and ability to run commands when it's disabled.

1 Like

I created a new one in the midst of all this lol. Can I delete them both and start over . Then just add the new one to the dashboards?

Essentially yes, just make sure you do the normal cleanup before removing the smartly inject devices, taking them out of any dashboards or other apps where you have referenced them, then create the new one and add it to any dashboards you need.

1 Like

Should I create the new one with that line of code in the driver modified?

I also did a repair install in HPM in all of this.

Yes,

Cleanup the existing devices and update the driver code (order not important).
Create the new smartly inject device (could technically happen before the driver is updated)
Run the Refresh command on the new Smartly Inject device
Add the device to any dashboards you want

I deleted the old smartly inject devices, had to disable them then delete. Deleted all files in file manager . Did a repair in HPM. Modified code in driver as posted in the other thread. Created new virtual inject device but it will not even load when its just created so i cannot refresh the device.

In any case seems to be working tho.

That might be ok, I could have got that wrong re the need for the refresh... Let me check.. Try adding it to a dashboard.

EDIT - Yep, the refresh happens when you create the device. It was only that I was messing around with code and other things I needed to do it on an existing device. I'll tweak the steps I posted on the other topic. Thanks for noticing that.

3 Likes

No problem, thank you. Its all working now.

2 Likes

Excellent. Simple... :slight_smile:

3 Likes