Closed Spartacus68 closed 5 months ago
This is how Pro/Plus devices without the power metering work. The workaround is a script that is installed on the device. Check if the script is installed and enabled.
Hi Maciej,
the script is running...
ok, I have it you mean this script. mqtt-switch-status-announce.js
I mean this one shellies_discovery_gen2_script_20240216. This script sends status every 30 seconds and the state of the switch will be updated.
hm, I am confused. The scriot is installes and running, but it seams to be not working correctly with the Pro 1. On my Pro 1 PM everything is fine.
And by the way:
MQTT.setConnectHandler(SendDeviceStatus);
let UpdateTimer = Timer.set(30000, true, SendDeviceStatus);
30.000ms are 5 minutes not 30s, isn´t it?
here is the script which was installed automatically:
let topic_prefix = null;
let installed_version = null;
Shelly.call("MQTT.GetConfig", {}, function (config) {
topic_prefix = config.topic_prefix;
});
function SendDeviceStatus() {
let _device_info = Shelly.getDeviceInfo();
installed_version = _device_info.ver;
Shelly.call("Shelly.GetStatus", {}, function (status) {
status.sys.installed_version = installed_version;
MQTT.publish(topic_prefix + "/status/rpc", JSON.stringify(status));
});
};
MQTT.setConnectHandler(SendDeviceStatus);
let UpdateTimer = Timer.set(30000, true, SendDeviceStatus);
Sorry, I was wrong, the JS script is not able to force the switch states to be updated. It forces updates of the sensor states.
Switch entities will get the correct state when you run Shellies Announce automation, check if this automation runs after HA starts, if not, you need add some delay.
Hi Maciej,
I checked it and included a delay, but it is still not working. I also triggerd the script manually and the status of the shelly is not set correctly.
alias: Shellies Announce Gen2
description: ""
trigger:
- platform: homeassistant
event: start
action:
- delay:
hours: 0
minutes: 0
seconds: 10
milliseconds: 0
- repeat:
for_each: "{{ device_ids }}"
sequence:
- service: mqtt.publish
data:
topic: "{{ repeat.item }}/rpc"
payload: "{{ device_info_payload }}"
variables:
device_info_payload: >-
{{ {'id': 1, 'src':'shellies_discovery', 'method':'Shelly.GetConfig'} |
to_json }}
device_ids:
- wc
- bad
- fynn
- wohnen.links
- wohnen.rechts
- schlafen
- buero
- gh.spots.schrank
- gh.deckenlicht
- gh.fan
- gh.halogenstrahler
- schlafen.charger
- E01
- K04
- K05
btw.
this script works fine, but it is an additional script which runs in parallel.
but it is still not working
That means your configuration is wrong.
but it is an additional script which runs in parallel
This is your device and your script. Are you sure the device is configured by Shellies Discovery?
Hi,
ok, maybe the configuration is wrong! The Device name ist K05, the mqtt prefix is also K05. The Client ID is IR.Sender. In the Shelly announce script (see above) K05 is configured, but not the client-id. Is it wrong?
but it is still not working
That means your configuration is wrong.
but it is an additional script which runs in parallel
This is your device and your script. Are you sure the device is configured by Shellies Discovery?
yes, it was automatically configured and if I delete the script from the Shelly it will be reconfigured
Is it wrong?
I don't know, I won't analyze a configuration with two different integration methods. I checked, the script works properly for Pro 2, so it must also work for Pro 1. The problem is somewhere in your configuration and you need to find it.
ok. then it is like it is
For me everything seams ok. All Pro 1PM are working correctly. Only the Pro 1 has the issue. mqtt-Explorer shows rhe correct status of the output (false)
{
"ble": {},
"cloud": {
"connected": false
},
"eth": {
"ip": null
},
"input:0": {
"id": 0,
"state": false
},
"input:1": {
"id": 1,
"state": false
},
"mqtt": {
"connected": true
},
"script:2": {
"id": 2,
"running": false,
"mem_free": 24220
},
"script:1": {
"id": 1,
"running": true,
"mem_used": 980,
"mem_peak": 4844,
"mem_free": 24220
},
"switch:0": {
"id": 0,
"source": "init",
"output": false,
"temperature": {
"tC": 26.1,
"tF": 79
}
},
"sys": {
"mac": "EC62608B3D04",
"restart_required": false,
"time": "15:42",
"unixtime": 1712670167,
"uptime": 1153,
"ram_size": 258728,
"ram_free": 112324,
"fs_size": 524288,
"fs_free": 192512,
"cfg_rev": 28,
"kvs_rev": 0,
"schedule_rev": 0,
"webhook_rev": 0,
"available_updates": {},
"reset_reason": 3,
"installed_version": "1.2.2"
},
"wifi": {
"sta_ip": "172.16.50.81",
"status": "got ip",
"ssid": "50gHack",
"rssi": -68
},
"ws": {
"connected": false
}
}
Hi, I do not find the config error: MQTT-Explorer
{
"ble": {},
"cloud": {
"connected": false
},
"eth": {
"ip": null
},
"input:0": {
"id": 0,
"state": false
},
"input:1": {
"id": 1,
"state": false
},
"mqtt": {
"connected": true
},
"script:2": {
"id": 2,
"running": false,
"mem_free": 24220
},
"script:1": {
"id": 1,
"running": true,
"mem_used": 980,
"mem_peak": 4256,
"mem_free": 24220
},
"switch:0": {
"id": 0,
"source": "init",
"output": false,
"temperature": {
"tC": 26.2,
"tF": 79.2
}
in HA it looks like this:
K05 IR.Sender (switch.k05_ir_sender)
MQTT discovery data:
Topic: ~status/rpc
Payload
name: IR.Sender
command_topic: K05/rpc
payload_off: >-
{"id":1,"src":"home-assistant","method":"Switch.Set","params":{"id":0,"on":false}}
payload_on: >-
{"id":1,"src":"home-assistant","method":"Switch.Set","params":{"id":0,"on":true}}
state_topic: K05/status/switch:0
value_template: '{%if value_json.output%}on{%else%}off{%endif%}'
state_off: 'off'
state_on: 'on'
availability:
- topic: K05/online
payload_available: 'true'
payload_not_available: 'false'
- topic: K05/status/rpc
value_template: '{%if value_json.mqtt.connected%}online{%else%}offline{%endif%}'
unique_id: shellypro1-ec62608b3d04-0
qos: 0
device:
connections:
- - mac
- EC:62:60:8B:3D:04
name: K05
model: Shelly Pro 1
sw_version: 20240223-142004/1.2.2-g7c39781
hw_version: gen2 (SPSW-001XE16EU)
manufacturer: Allterco Robotics
configuration_url: http://shellypro1-ec62608b3d04.local/
origin:
name: Shellies Discovery Gen2
sw_version: 2.28.0
support_url: https://github.com/bieniu/ha-shellies-discovery-gen2
platform: mqtt
Your Shellies Discovery Gen2
automation looks wrong.
Hi,
indeet! I never changed this during inital setup in April 2023. Is this what I have to check on a regular basis? I thought it will be modified automatically once an update applies.
I replaced it and now it seems to be working. But only if a delay is configured in the announceGen2. Otherwise the issue is still present.
Describe the bug
after HA reboot, the status of the output is "unknown". After setting it manually, it is working.![image](https://github.com/bieniu/ha-shellies-discovery-gen2/assets/121975453/62b88f3e-4da2-4355-af54-d56817e9aa54)
Expected behavior
Status should be "off" as it is on the Shelly Pro 1 PM
Here is also the mqtt-Explorer output:
Versions:
Home Assistant:
Shellies Discovery GEN2: 2.28.0
Shelly device firmware: 1.2.2
Shellies Discovery GEN2 automation:
Shelly device MQTT settings:
Debug log: